LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2005, 07:28 AM   #1
fssengg
Member
 
Registered: Feb 2005
Location: Kerala(God's own country)
Distribution: Redhat-8
Posts: 35

Rep: Reputation: 15
Question what is the difference between socket & port?


hai
Can anybody tell me what is the fundamental difference between a socket and a port?
How they r represented actually?
 
Old 05-15-2005, 08:52 AM   #2
Vookimedlo
Member
 
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 34
Port represents service, which computer offers in the network.

Socket is communication resource.
 
Old 05-15-2005, 10:47 PM   #3
raviksp
LQ Newbie
 
Registered: Apr 2005
Location: engineer
Posts: 1

Rep: Reputation: 0
Port is application running on that socket.So port uses Socket to deliver the pkt to correct application.
Socket is communication resource.POrt is just to identify the one among many applications running on that socket..
 
Old 05-15-2005, 11:07 PM   #4
Maelstrom65
LQ Newbie
 
Registered: May 2005
Location: Victoria BC, Canada
Distribution: Fedora Core 3
Posts: 4

Rep: Reputation: 0
The way I understand it is...

A port is (as was mentioned already) a service or resource. The way into and out of an application. When you call up a web page, you're calling to port 80 on the target machine from some port between 1024 and 65,535 on your machine (called Ephemeral Ports)... When those two ports establish communication (you download your webpage) a "Socket" is created. Kinda like a circuit I guess.

Hope that makes sense...

Cheers
 
Old 05-16-2005, 12:05 AM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Ok, since everybody else is doing it...

A port is a service provided by a machine. That service is identified by a number. There are a lot of standardized port numbers for popular services. Port 22 is for FTP. Port 80 is for HTTP. There are many, many others.

A socket is the way a server and a client keep track of requests. For example, LQ.org allows access to port 80 (HTTP) for the purposes of reading these forums. When my computer requests to see the content of the forums, a socket is created, and a "conversation" between the server and my machine occurs. The thing is, I'm not the only person trying to read the forums. So, to keep the server from getting conversations mixed up, each request gets a different socket. As I recall, there can be 64K sockets (or simultaneous conversations if you prefer). The thing to note is this: that's 64K sockets per port, because all these requests are coming into the server on port 80, right?

So, ports are a broad reference to a type of service, whereas a socket refers to a specific connection on a specific port.

EDIT:
Oh, forgot... ports and sockets are both typically represented as integers. At I fairly certain; both can take a value from 0 to ( 64K - 1 )

Last edited by Dark_Helmet; 05-16-2005 at 12:07 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect server with muliple port via socket husniteja Programming 0 08-21-2004 02:25 AM
Close socket/port THETEZ Linux - General 4 03-28-2004 08:05 PM
Why is my socket unable to bind to the port in the C Code. mcp_achindra Programming 10 03-24-2004 08:34 AM
Socket binding to port problems Xris718 Linux - General 0 07-10-2003 01:04 PM
about socket port Ivan Lee Programming 4 03-20-2003 03:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration