Socket Programming in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Socket Programming in Perl
# 1  
Old 09-14-2012
Socket Programming in Perl

Hi All
I am getting an error when using the below code
Receiver
Code:
use IO::Socket;
$sock = new IO::Socket::INET (LocalHost => 'goldengate',
LocalPort => 1200,
Proto => 'tcp',
Listen => 5,
Reuse => 1
);
die "Socket could not be created. Reason: $!" unless $sock;
while ($new_sock = $sock->accept()) {
while (defined ($buf = <$new_sock>)) {
print $buf;
}
}
close ($sock);

Sender
Code:
use IO::Socket;
$sock = new IO::Socket::INET (PeerAddr => 'goldengate',
PeerPort => 1200,
Proto => 'tcp',
);
die "Socket could not be created. Reason: $!\n" unless $sock;
foreach (1 .. 10) {
print $sock "Msg $_: How are you?\n";
}
close ($sock);

The Error is Socket could not be created.
Please provide the remediation for this..
# 2  
Old 09-14-2012
What is 'goldengate'?
# 3  
Old 09-15-2012
I just keep the the name of Local Host
I think we can keep it any , it doesn't effect anything right??
# 4  
Old 09-15-2012
Is IP mapping is done to "goldengate" in your box where you are executing tour client program.

Quote:
PeerAddr => '<IP/Hostname>'
PeerAddr can be IP or hostname of the remote server.
# 5  
Old 09-15-2012
That's Done, Thank You..
One more thing I want to ask, Is it possible to send the file (without opening it) through Socket.
# 6  
Old 09-17-2012
It's not possible to send a file without opening it. Something, somewhere, must call the system call open() to access the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Socket programming

Hi everyone, I'm new to this forum. I'm working on new project for last few days and this forum already helped me on couple of occasions. I don't have any prior experience with network programming so I'll appreciate any advise given. I'm trying to do the following: 1. open user... (2 Replies)
Discussion started by: _thomas
2 Replies

2. UNIX for Dummies Questions & Answers

hi i need help with socket programming

in socket programming how can i : Create for example 3 blank files, namely: server, client, network •Server: act as servers/provider, will receive all requests from different client •Client: requesters •Network: middle-layer of communication between server & client any tips or... (6 Replies)
Discussion started by: kedah160
6 Replies

3. UNIX for Dummies Questions & Answers

Socket programming

in c socket programming, how can I send and received on the same port? (7 Replies)
Discussion started by: Peevish
7 Replies

4. UNIX for Advanced & Expert Users

socket programming

can we send udp message to a destination ip address .. without having an ip address configured in our machine using recvfrom ? (2 Replies)
Discussion started by: Gopi Krishna P
2 Replies

5. UNIX for Advanced & Expert Users

socket programming

Hi, I am trying to connect to more than 60 servers to perform some actions remotely. for this I am using ssh2. But its taking lot of time. Though i am running the command in background, still its taking long time to execute.. Any one let me know can we use sockets instead of ssh2 for... (3 Replies)
Discussion started by: pvamsikr
3 Replies

6. Shell Programming and Scripting

simple socket programming in perl

hi i want to write simple socket program which will listen on socket . here is the code ## read msg on socket #! /usr/bin/perl use IO::Socket::INET; my $MySocket= IO::Socket::INET->new(LocalPort=>1234, Proto=>'udp') ; while ()... (2 Replies)
Discussion started by: zedex
2 Replies

7. IP Networking

socket programming

Hello Everyone Iam working on tcp/ip programming.with some time interval server has to send data.client has to close the connection and to open the connection between the time interval.this is the scenario when iam closing the connection in client side the connection terminates.how to... (1 Reply)
Discussion started by: sureshvaikuntam
1 Replies

8. IP Networking

socket programming

my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing... how can i do that....? (6 Replies)
Discussion started by: damn_bkb
6 Replies

9. Programming

Socket Programming socket

Hello, I actually try to make client-server program. I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error : I'm just using this simple code : and I get the same error if I use : If someone can help me, Thanks (2 Replies)
Discussion started by: soshell
2 Replies

10. Programming

Socket Programming

Dear Reader, Is there any way to check up socket status other than 'netstatus ' Thanks in advance, (1 Reply)
Discussion started by: joseph_shibu
1 Replies
Login or Register to Ask a Question