The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-20-2005
Registered User
 

Join Date: Feb 2005
Posts: 3
Post Confusion about TCP/IP socket programming

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
Reply With Quote
Forum Sponsor
  #2  
Old 02-20-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
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.
Reply With Quote
  #3  
Old 02-20-2005
Ee77's Avatar
Registered User
 

Join Date: Feb 2005
Posts: 15
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.
Reply With Quote
  #4  
Old 02-20-2005
Registered User
 

Join Date: Feb 2005
Posts: 3
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0