Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to bind ip addres with interface ( procces )

Status
Not open for further replies.

nimberg

Programmer
Sep 14, 2000
8
0
0
IL
how to bind ip addres with interface ( procces )
i have an ip that i want to bind a procces to it
is ther a way to do it in uinx ?
10x
 

you have to use :
socket, bind, listen, accept functions and the sockaddr_in structure at least!

first you have to create a socket witch will be you listening_access_point ( _lap )

_lap = socket (AF_INET, SOCK_STREAM, 0)

than you set the sockaddr_in structure
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = port;

then you bind your _lap to an address
bind (_lap, (struct sockaddr *)&serv_addr,
sizeof (struct sockaddr_in)) < 0)

than you begin listening at that address
listen (_lap, GRA_GN_MAX_TCP_BACKLOG) < 0)

in this example accept is a blocking call returning only when i client attepts a connect call to your address
ssn = accept (_lap, (struct sockaddr *)&amp;addr,
(GRA_sSize *) &amp;len);

ssn is the session you have with the client

have a look on man pages for dettail
Hope it helped!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top