473,396 Members | 1,853 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,396 software developers and data experts.

Getting Local Port Number in Perl

darksteel21
Hi to all,

I am currently developing an application in perl that is capable of connecting to a server and sends information..
the server has a deamon that listens to the socket connections. It requires a socket port number of the client used in making a socket connection for validation..

is there a way in perl in which i can get the local port number (client side) used in making a socket connection to the server?(using Socket and IO:Socket libraries only)

Regards,
Mark Tan
Apr 27 '09 #1
6 4214
Icecrack
174 Expert 100+
Let me clear up on this, you are trying to get the client to send its port to the server for auth?

or are you trying just to find out what port the client is running on?
Apr 27 '09 #2
I am trying to get the client to send its port to the server for authentication...
my perl script resides on the client..
Apr 27 '09 #3
Icecrack
174 Expert 100+
how are you calling your socket

have you tried?

socketpair(DOMAIN, TYPE, PROTOCOL)
Apr 27 '09 #4
i am using these codes :
Expand|Select|Wrap|Line Numbers
  1. $r_socket = IO::Socket::INET->new(PeerAddr => $ServerIP,PeerPort => $ServerPort,Proto => 'tcp') or die("Socket Error Connection");
I am using the IO:Socket module
Apr 27 '09 #5
RRick
463 Expert 256MB
You are almost there, the following methods will supply the info you need.

The following methods can be used on socket filehandle objects created by IO::Socket::INET:

* sockaddr
* sockport
* sockhost
* peeraddr
* peerport
* peerhost

For more info try http://docstore.mik.ua/orelly/perl/perlnut/ch13_02.htm
May 5 '09 #6
thanks for these information, i'll study these methods...
May 6 '09 #7

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

Similar topics

1
by: Ashley Harris | last post by:
I hope to have a Linux box sitting in the boot of my car using perl and some CPAN modules for Ogg-Vorbis and Audio Streaming for a home-built stereo system. I recently scored a GPS locater that...
1
by: Bruce Wood | last post by:
I'm having a devil of a time calling DeviceCapabilities() in order to get the list of paper names / codes / sizes for a printer. Here is my code and the input it produces: static extern Int32...
2
by: William GS | last post by:
Hello, my app sends and receives messages over a local area network using WinSock, so I need a Port, How can I get an unused port? It must work with VC6 and Win98/ME too. Thanks in advance,...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
0
by: robpimentel | last post by:
Hi, I've been using DB2 for about 1 week, so please bear with me. DB2 Connect Enterprise Edition v8.1 FixPack 5 Windows Server 2003 Standard Edition SP1 Here is an error that continues to...
31
by: damacy | last post by:
hi, there. i have a problem writing a program which can obtain ip addresses of machines running in the same local network. say, there are 4 machines present in the network; , , and and if i...
5
by: naamala | last post by:
Hi, How can i get unused/available port in the local system using C# ? Or Is there any way to find out whether the particular port number is being used by any other application using C#? ...
1
by: bhavanirayala | last post by:
Hello, I am using XML::Parsar in my perl file. but when I run the perl file, getting the following erro even I have the parser.pm and Dynaloader.pm files in the lib path. The error is: Can't...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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...

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.