TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Russell Coker
from: Jim Archer
date: 1995-04-21 18:31:04
subject: Tcp/Ip And Sockets

RC>  JA> There are some very important differences in programming TCP/IP for
RC>  JA> unix and OS/2. The unix book is OK for the general concepts, but some
RC>  JA> aspects are different, most notably error handling and controlling
RC>  JA> blocking. Unfortunatly, I have been unable to find a descent book, in
RC> 
RC>    In what way?  I admit I haven't gone very far into 
RC> TCP/IP programming in UNIX, but from what I've seen there's 
RC> no major difference that counts.  The UNIX books are great 
RC> for the theory, and then the IBM doco is satisfactory for 
RC> information on parameters...  The hard part is working out 
RC> the theory, once you've got that there's no major hassle 
RC> with parameters for functions etc.

Well, one major and important way is in error handling. You can't just
check errno like under Unix. To get the errno, you have to call
sock_errno(). Then, all the macros definde, like EINTR and EAGAIN, are
different. I don't think EAGAIN exists, and EINTR is SOCEINTR, or
something like that. Also, there are lots of new ones which you must
check for. This is a good example of how bugs can creap into a program.
If you put ordinary code into a program that checks errno and compares
against the standard macros, then you have no error checking. But, on a
test LAN, things may chug along just fine. On a big real LAN, boom!

Another example is in blocking. Use the select() call to control the
blocking mode of a socket. I have found that its best to call select()
against a socket to check to see if any data is in the socket before I
read it. Select() can time out, but recv() can not. If you call recv(),
and the program accross the wore goes away, your thread is blocked
indefinately. Since OS/2 has a maximum thread limit, you don't want
this happening in a server.

Also, I found the docs that come with the toolkit vacume. FOr example,
look at the explanation of the send() function. No where does it
explain that send may send some, but not all, of the data it is asked
to send. In fact, nowhere does it explain that send() actually returned
the number of bytes sent.

Im not saying that you can't write wounderfully reliable TCP/IP code
under OS/2. You can, and my server seems to work nicely. But, you have
to throughely study the BOO files that come with the toolkit, and not
assume that anything works like it does under unix. Many things do, but
enough don't to get into trouble.

Good luck!

Jim

 * KWQ/2 1.2i * Fear not, till Birnam Wood; Do come to Dunsinane! (V, V)

--- Maximus/2 2.02
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.