Mail Archives: djgpp/1998/01/30/14:17:22
On Fri, 30 Jan 1998 13:15:49 GMT in comp.os.msdos.djgpp Grzegorz Adam
Hankiewicz <gregorio AT jet DOT es> wrote:
: >> Does anybody know if I can create a network program (TCP/IP or IPX)
: >> and test it on one machine. Kinda like the Linux virtual consoles. Can
: >> I startup 2 MS-DOS screens and have the two programs communicate with
: >> each other?
: >
: >i haven't tried it, but it should be possible. wouldn't really be like
: >linux virtual consoles though.
: >
: >it works with NetBIOS.
: This is interesting. Can you give more information about this? Is
: there any tutorial which teaches how to set this up? (the
: communication with two DOS sesions)
I can't speak for NetBIOS, only for Winsock. Yes, it's definitely
possible; it's my only (convenient) way of testing network programs
that I write ;).
It really is simple; given a sockets library, or anything capable of
using Winsock, start one program and make it bind a socket to a
certain port (or use 0 and then getsockname to find out which port it
actually used). Then, start the other program and make it talk to the
first one, using the loopback address (127.0.0.1 == INADDR_LOOPBACK if
the constant is defined) and the same port as the target address.
With TCP a connection is now made and through a little trickery the
first program moves the connection onto a different port; with UDP
this doesn't happen automatically, but is generally a good thing to do
anyway.
With most libraries you'll need a basic understanding of how sockets
work, so that you know when to bind to a port explicitly. Using
libnet the knowledge isn't so important, not at that low level anyway;
you just explicitly create an `input' channel when you want to receive
connections. The chat client/server example shows a way to shift a
client onto a different port after the connection is established
(libnet uses UDP).
Tests show that the Winsock is actually quite a fast way to
communicate. It only supports AF_INET with [SOCK_STREAM and
IPPROTO_TCP] or [SOCK_DGRAM and IPPROTO_UDP] though.
If you're really interested in more details on this, let me know
privately and I can explain in more detail/accuracy and send examples.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -