473,431 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,431 software developers and data experts.

streaming data over socket

I am looking for a way to send data over a socket to a specified host and port. it is a 1 way street I am only sending the tail of a log file. Looking for something really simple that sends the tail whenever there is one. Do I need to establish a connection on the socket and is it possible with out there being a perl script at the recieving end?

Thanks for the help
Jul 31 '07 #1
4 4456
KevinADC
4,059 Expert 2GB
This is something I have little pratical experience with, but you can look into using the IO::Socket module to set up the socket communication.

http://perldoc.perl.org/IO/Socket.html

I assume there does not have to be another perl script, but there has to be something to recieve and process whatever data you send to the server.
Jul 31 '07 #2
use File::Tail;
use IO::Socket;

# init host and port
my $host = 'ip_addr';
my $port = 7777;
my $name = 'C:\requestDiag.log';
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket: $!";

$file=File::Tail->new(name=>$name, maxinterval=>300, adjustafter=>7);

while (defined($line=$file->read)) {

$sock->send('$line');
print "$line";
}
close($sock);

Here si what I think from ready should work to send each tail of a log file over a socket. However, this does not seem to be working.

Any one have any ideas?
Jul 31 '07 #3
KevinADC
4,059 Expert 2GB
if everything else is OK, changing this ine:

$sock->send('$line');


to:

$sock->send($line);


should work.

When you put single-quotes around a scalar it literally means what is inside the quotes: $line, and not whatever value the scalar $line interpolates to. Is File::Tail installed?
Jul 31 '07 #4
Thanks for the help there.

Yes file tail module is installed, but the socket closes what seems to be every time the tail stream tries to send over that socket. I need to keep the socket open and continuously send a 1 way stream over it to a client. the connection is "established" according to netstat at both ends but the data streaming does not work.
Aug 1 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MyHaz | last post by:
I playing around with streaming shoutcast mp3s. Here is some sample code: ----------------------- import httplib ############ # Put together the headers headers = {"Icy-MetaData":"1"}
22
by: googlegroups | last post by:
I am playing with the XMLHTTPRequest method to perform client/server transactions. I have it set up right now so that when readyState is 4, it takes the XML and processes it. This works great until...
1
by: Patty O'Dors | last post by:
I've heard the phrase "streaming data into a rich text box" and I want to know whether it means what I hope it means. What I hope it means, is that if the user pastes a whole load of text into...
5
by: John | last post by:
Hi all, I have an (well, what I think to be, at least) interesting question: Is it possible to stream data down to the client and, after a certain amount of data has been streamed, allow the...
1
by: bordsby | last post by:
VB.NET, Windows XP Pro I am writing an application that streams financial numbers from Bloomberg, and basically every time Bloomberg's API raises an event in my application I receive all of the...
3
by: Vijay | last post by:
Hi Folks, I having one issue, in my application I am going to use the server push for streaming the data by keeping the connection open. At client side, i am having the XMhttprequest object (i.e...
2
by: Changhao | last post by:
Hi, friends, I am implementing a protocol on top of 'asyncore.dispatcher' to send streaming multimedia data over TCP socket. However, I found that the throughput of my current implementation is...
0
by: Søren M. Olesen | last post by:
Hi I have a situation, where I'd like one thread to write data to a stream and another thread to read data from the same stream at the same time.....is it possible? and if so, how do I implement...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.