![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help regarding socket programming | abmxla007 | High Level Programming | 1 | 05-27-2008 11:17 PM |
| socket programming | sureshvaikuntam | IP Networking | 1 | 04-21-2008 05:38 AM |
| Socket Programming | arunviswanath | High Level Programming | 7 | 01-30-2007 12:18 PM |
| Socket Programming socket | soshell | High Level Programming | 2 | 06-29-2004 04:49 AM |
| Socket programming | Nadeem Mistry | High Level Programming | 1 | 07-23-2001 01:33 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hello there chaps.
First of all, i'm no TCP/IP-wiz, so forgive me if this is a stupid question. I've been messing around with filetransfer using sockets, and there is one thing that confuses me. This is how it's set up: A server app listens on a port for a client connection. When it receives a connection, it forks and reads some stuff (file length, name etc.). Then it starts reading from the socket, saving the data in a local file. Now if i make two client-connections to this server, sending two different files, it's still able to receive both files through the same port simultaniously. How is that possible? I'm guessing it has to do with different filedescriptors, but i'd like to know in detail how the kernel keeps track of which data to send to which file descriptor. Also, is this a bad way to go about filetransfer? Should i use separate ports for data and client connection? /Crippe |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I'm not completely sure that I follow your question. But if you asked what I suspect that you asked.... A socket is defined by four data: local ip address, local port, remote ip address, remote port. Two different sockets will have something different. If I open two telnet windows from my pc to a unix host, my pc will allocate a different local port. That is enough to keep the sockets separate.
|
|
#3
|
||||
|
||||
|
I think you are looking at only the source port. You have to understand that if lets say i try to telnet you, the destination port of the connection would be 23 and the source port would be who knows what.
|
|
#4
|
|||
|
|||
|
Ah, I understand now. I was thinking of a port as a physical medium or something, how silly of me. :P
Thanks for the replies! /Crippe |
|||
| Google The UNIX and Linux Forums |