simple tcp/ip problem

I wrote a simple Server and Client, they communicate through Stream
communication.
everything works fine, But in Server’s code, I have to print out the port
number the server binds
to, then pass in the port number as a argument into client… Is there a way
I can assign
a fixed port number instead of Binding?

Hi Ran,

For the server you can specify a port number as long as it is greater
that 1024 ( you need to be root to use one lower than that)

Server

server.sin_port = any number over 1024 ( i.e. 5000);

Client

name.sin_port = same number you chose for the server

Hope this helps
Regards
Brenda



ran zhang wrote:

I wrote a simple Server and Client, they communicate through Stream
communication.
everything works fine, But in Server’s code, I have to print out the port
number the server binds
to, then pass in the port number as a argument into client… Is there a way
I can assign
a fixed port number instead of Binding?