[comp.os.os2.programmer] How do I detect an active TCP/IP

dzoey@terminus.umd.edu (Joe Herman) (03/20/91)

Hello, I have a program running under OS/2 that would like to take advantage
of TCP/IP if it's installed on the machine.  Unfortunatly, I can not think
of a good way for the program to detect the presense of TCP/IP.

At first, I thought this could be done by checking the return code
from the socket() (or sock_init()) call.  However, if inet is not
functioning the call to socket() causes the program to exit.  Since
the program can still function without TCP/IP, this is not a desired
behavior.

Does anyone know of a method to detect the presense of TCP/IP under OS/2?

			Thanks,
			Joe Herman
			U. of Maryland

dzoey@terminus.umd.edu
-- 
"Everything is wonderful until you know something about it."

wbonner@eecs.wsu.edu (Wim Bonner) (03/24/91)

In article <8281@umd5.umd.edu> dzoey@terminus.umd.edu (Joe Herman) writes:
>from the socket() (or sock_init()) call.  However, if inet is not
>functioning the call to socket() causes the program to exit.  Since
>the program can still function without TCP/IP, this is not a desired
>behavior.

Is the socket call in a DLL?  If so you may be running into a similar problem
I've had with my network programming in that all of the LANMAN calls are 
actually located in DLLs, and so the first call kills the program.  The solution
that was suggested to me, was to try to demand load the call and if that was 
successful, assume the network was loaded and make the call.  If you cannot 
demand load the call, the DLLs are not available, so don't make any network 
calls.

Unfortunately, I'm not at my own computer right now, so I can't post the 
suggested code.  I'll try to remember to put it up tomorrow when I can get to my
computer.

Wim.
-- 
|  wbonner@yoda.eecs.wsu.edu  |
| 27313853@wsuvm1.csc.wsu.edu |
|  72561.3135@CompuServe.com  |

ibmman@eng.clemson.edu ((the) IBMMAN) (03/25/91)

Even if you can demand load the call, that doesn't mean that the TCP/IP
software is running, although this is usually the case.

Cheers,
Q

oleg@arnor.UUCP (03/26/91)

In article <8281@umd5.umd.edu> dzoey@terminus.umd.edu (Joe Herman) writes:
>from the socket() (or sock_init()) call.  However, if inet is not
>functioning the call to socket() causes the program to exit.  Since
>the program can still function without TCP/IP, this is not a desired
>behavior.

INET.EXE allocates a shared segment \SHAREMEM\MAILBOX. You can check
if the segment is allocated before making the first socket call.

Oleg Vishnepolsky