Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to get PortNumber of a PC to send it some text message and I need to get it programmatically ... How can I do that ?

thanks in advance
Posted
Comments
Mahesh Bailwal 8-Oct-13 3:07am    
Do you have any server application running on target machine where you want to send text message?
Mehdi Gholam 8-Oct-13 3:08am    
Any computer has multiple ports so you can't get a "port number of a pc", you can however see if you can connect to a known port on a pc.
marimir 8-Oct-13 3:10am    
Yeah I know it has multiple ports ... but I want to use one of them .. how should I get one of them ?!
marimir 8-Oct-13 3:15am    
Actually I'm trying to write a chat program and I want to send message between clients ...
so I need a unique port number for all of the computers in a network ...and I send the message by using portnumber and IP ...
How to get a portnumber in program?
Mehdi Gholam 8-Oct-13 3:18am    
You should already know your port number since you are communicating via that port, if you can't decide just pick a port (1234 for example) and write your program with that.

1 solution

There is no such thing. A port number is a property of an application, not a computer. In particular, you can open a TCP socket and listen on some port. Many different ports can be used at the same time.

—SA
 
Share this answer
 
Comments
marimir 8-Oct-13 3:42am    
thank you Sergey Alenxandrovich Kryukov ..
your answer was useful
Sergey Alexandrovich Kryukov 8-Oct-13 10:32am    
Very good.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900