tcp client socket : how to get own port number ??
Hi,
I am working with simple tcp client to establish connection to sockaddr_in servAddress and send data segment: ... connect(sockfd,&servAddr,sizeof(servAddr)) < 0) send(sockfd, pkt, pktLen, 0); close(sockfd); ... Elementary... Here's the tricky part: next i have to handle user level ack the server is sending to "client"... To do that i have to open server socket on the same port number the system assigned to my client socket before. How can i get it ( in user level code)? Thanks, -V |
Code:
connect(sockfd,&servAddr,sizeof(servAddr)) < 0) |
I sounds like you are asking how to do bi-directional communcations on a socket. The answer is too simple: each end of the connection is a read/write file descriptor. Simply leave the socket open until all of the communication has transpired in each direction.
--- rod. |
All times are GMT -5. The time now is 06:03 AM. |