![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: May 2005
Location: ma
Posts: 130
Rep Power: 4
![]() |
simple exercises to play around with sockets?
hi. i've been reading about socket programming lately and want to get my hands dirty. Is there any exercises i could to to mess around with them? I don't have two linux boxes so i can't make a real connection but is it possible to connect back to myself connection 127.0.0.1? In that case would it be difficult to tell if i was successful or not? thanks for any replies in advance.
|
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
yap, you can connect to yourself via 127.0.0.1, but make sure you don't connect on the same port
![]() |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: May 2005
Location: ma
Posts: 130
Rep Power: 4
![]() |
to make sure im doing it right would it be just as simple has having two shells opened and sending the data to standard input?
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Have two shells open... one for the client and one for the server. Use 127.0.0.1 has the IP for both... just send and receive on unique ports... do not have them be the same and don't have them be a port that is already in use by a known service (ie httpd=80).
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
The point we are mentioning though, is the client can't use the same port as the server on the same system. |
|
|
|
|
|
|
#7 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#8 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
Just that two programs on the same system can't use one port at the same time (maybe with some kernel hacking, but you get the point ). |
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
I think you're getting confused with how TCP/IP works, or I'm just not understanding what you're getting at. Binding to a port only matters when you're listening. So, for instance, I have a HTTP server listening on port 80 on my computer. I couldn't start another HTTP server and tell it to listen on port 80, because that's already taken.
But I can point multiple browsers to my one HTTP server. I can have two clients connected to the same port at the same time on the same system. So your assertion that "the client can't use the same port as the server on the same system" doesn't make sense to me, because clients typically don't need to bind to a port. Only protocols like FTP, where the client also has to listen to incoming connections from the server, would this make any sense at all. |
|
|
|
|
|
#10 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
I still have to learn much ![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|