Socket Source code Example

Socket Source code Example

Post by Limbree Christoph » Thu, 03 May 2001 03:20:33



I would like to program TCP/IP socket under LINUX. I want to establish a
communication between 2 processes running on 2 different computers. I
need some source code to start. Can you provide me some source code
(server and client) ?

Thanks a lot.

Limbre Christophe

 
 
 

Socket Source code Example

Post by A.C. 'Static' Stad » Thu, 03 May 2001 11:44:23



> I would like to program TCP/IP socket under LINUX. I want to establish a
> communication between 2 processes running on 2 different computers. I
> need some source code to start. Can you provide me some source code
> (server and client) ?

> Thanks a lot.

> Limbre Christophe


While I hate to use what I generally refer to as "media hype terms", I'm
going to assume you've heard the term "open source"?  Download some source
code for some/any program that uses TCP... pull it apart and try to figure
out how it works.  Better yet, read a book on the subject, not to be
deliberately offense to the other coders out there, but we often get a
certain way of doing things stuck in our heads, and always do it that way...
even if there are better ways.  Programming books on the other hand, are
generally written by multiple authors, and have multiple editors...
therefore by the time it gets to press, it has had, as a general rule, any
programmer bias stripped out of the sample code.  I believe someone just
made a post in this group regarding one such book: here it is, in a message
posted by Lew Pritcher,

"Do yourself a favour and read a couple of good books about TCP and
sockets programming. I'd recommend "Unix Network Programming: Volume
1" by W. Richard Stevens as an excellent startingpoint."

of course it also appears that Lew works for one of Canada's money hogs, but
I guess we can trust him here.
(Just kidding Lew, I used to work for TD myself).

St.

 
 
 

1. source code example of a socket problem

SO_REUSEADDR is to allow multiple sockets to bind to the same port without
failure.
I never want more than one process (or socket) to bind to that port at
any time.
When I run the program, when it terminates it should no longer be bound
to any port because all sockets are closed.
When I rerun the program, and it fails to bind that means that the system
still thinks some socket is bound to that port.  There are no such sockets
and no processes--It seems the internal tables of the OS which maintain
such addresses are not up to date or clear the use bit when I close the socket
in the first place.
Since I never intend more than one process (or socket) to bind to that port
at any point in time I should never have to use SO_RESUEADDR.

I'm not sure why this happens to work, but I think when the OS
receives a packet destined to a port which is no longer bound to any socket
in any process, it clears its table and then that port can be used.

Thanks,
David McLaughlin
--
Web: http://bert.cs.byu.edu/~dpm/homepage.html

2. xgettext/msgfmt: header problems

3. RSA or PGP source code/examples

4. how can I determine if an aix process is hung

5. IEEE 1394 application - example, source code

6. Where to find source code?

7. Example Source Code for "Go back n technique"

8. Interfacing with 'talk'

9. Can anyone give me a example source code of shell ??

10. Working Examples of PHP3 & mySQL, with source code

11. example networking code using socket, bind etc?

12. dlpi(7) and le(7) example source code

13. Looking for Glade examples online w/ source code