delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/30/14:17:22

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Network programming
Date: 30 Jan 1998 16:36:50 GMT
Organization: Oxford University, England
Lines: 49
Message-ID: <6asvj2$5c4$8@news.ox.ac.uk>
References: <6aq97c$jfp$1 AT bohol DOT infocom DOT sequel DOT net> <34D0BCFF DOT 6ADA AT cornell DOT edu> <34d1d234 DOT 5891844 AT news DOT jet DOT es>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019