TCPActiveOpen question

TCPActiveOpen question

Post by David Walt » Wed, 01 Apr 1998 04:00:00




> On TCPActiveOpen I am suppose to know the
> remote TCP port.  How do I find this?

> I set the ports to zero when setting up the stream
> or using Passive open so that TCP will just sign
> an unused port.

This is correct for the _local_ port.

Quote:> But when using active open I need to know the
> port of the remote host.    How do I find this?

Ports for well-known internet services generally have standard numbers
assigned to them (e.g., FTP is 21, POP is 110, etc.).  If you have access
to a UNIX workstation, you may be able to find a list of these numbers in
/etc/services.  If not, you can probably find it in one of the RFCs.

Here's a partial list of the ports from my local /etc/services; note that
although most server implementations will use these ports, there's no
requirement that they do.  The easiest way to confirm the port is to
telnet into the standard port number for the service you want, and see
what kind of greeting you get.  Of course, if you're using a non-standard
service, or some kind of custom protocol, you'll need to talk to the
server's administrator.

#
# Network services, Internet style
#
tcpmux          1/tcp
echo            7/tcp
echo            7/udp
discard         9/tcp           sink null
discard         9/udp           sink null
systat          11/tcp          users
daytime         13/tcp
daytime         13/udp
netstat         15/tcp
chargen         19/tcp          ttytst source
chargen         19/udp          ttytst source
ftp-data        20/tcp
ftp             21/tcp
telnet          23/tcp
smtp            25/tcp          mail
time            37/tcp          timserver
time            37/udp          timserver
name            42/udp          nameserver
whois           43/tcp          nicname         # usually to sri-nic
domain          53/udp
domain          53/tcp
hostnames       101/tcp         hostname        # usually to sri-nic
sunrpc          111/udp         rpcbind
pop-2           109/tcp                         # Post Office
pop             110/tcp                         # Post Office
uucp-path       117/tcp
nntp            119/tcp         usenet          # Network News Transfer
ntp             123/tcp                         # Network Time Protocol

Hope this helps.

David Walton

--
David Walton                  | Graduate Student and Macintosh pundit

http://www.nd.edu/~dwalton1   | University of Notre Dame

 "Beware the advice of successful people; they do not seek company."  

 
 
 

TCPActiveOpen question

Post by Bink » Thu, 02 Apr 1998 04:00:00


Let me get this straight...

Your server opens a Passive TCP port which the clients connect to using
Active TCP.  The server ought to use a specific port number.  For
instance, the dafult web server port nuber is 80.  When your browser
connects to a web server it tries port 80 (unless you tell it
otherwise).  The clients then connect to your server using the default
port number (which you choose...use a high number, like 10000 or
something).  If the server is running on another port then the client
should give the user the option to enter a port number (quake does this,
marathon does this etc).  The client can connect using any port number.

The point being, it doesn't matter which port number is used on the
client machine because the server doesn't care.  What does matter is
that the client knows which port the server is using because the client
has to connect to the server, not the server to the client.

Once the passive server connection is open, the server can find out the
clients ip address and port number by looking at

thePB -> csParam.open.remoteHost;
thePB -> csParam.open.remotePort

I have a full CodeWarrior project and source etc for an example server
which shows how to do this sorta stuff.  Its not optimised for games but
it shows how to do this kinda stuff.  I can mail it to you if you like?
(its normally ftp-able but the server is down today)

binks
--
======================================================================

Macintosh Software Engineer                http://*.paperjet.com/
* Net, London, UK
======================================================================
                              *TURBO
                 Serving live video from your desktop
======================================================================

 
 
 

1. Questions, Questions, Questions

   I have a stream of bytes from which I have to extract a long.  (4
bytes)  Should I be concerned with 4-byte boundaries or can I just cast
the pointer.  And if I should be concerned, is the following a good (or at
least acceptable) way to do it or am I missing some obscure little detail?

/* [place is an unsigned char*] */
#define get4bytes(place)   \
   (0x0L |                 \
   *(place) << 24 |        \
   *((place)+1) << 16 |    \
   *((place)+2) << 8 |     \
   *((place)+3))

   Next, I have heard of "xoring pointers."  What the hell is that?

   Finally, what is the optimum way to use FSRead?  I assume it'd be best
to read in a large chunk, say 32k, at a time.  But how slow would it be to
make many tiny (on the order of a few dozen bytes) reads?  If it is
extremely slow to make many tiny reads at random locations in the file,
then is there a faster function?  The file will be too large to load into
memory.
   If it's just a little slow, then I don't care.  I'm not interested in a
speed deamon, I merely don't want it to crawl.

   Forgive the basic questions.  I haven't used the Mac file API directly
before and I've been off programming Lisp and FORTRAN for a few months, so
my C is rusty and my brain needs to be rewired.  (:

--
B.B.       --I am not a goat!

2. Discrete COLORBAR --------------

3. Question: Where can I ask MacOS X questions?

4. comp.dcom.isdn FAQ Location - Periodic Announcement

5. PP Questions (be warned! newbie questions!)

6. Indy R4000SC-100, 8 bit

7. Assorted questions about CW Pro 4 (including Java long names question)

8. Using MITs Kerborised telnet with Windows 2000

9. Question: Handles to Objects?

10. ATTN Ron: MW subscription question

11. Simple STRUCT question

12. Beyond 'Newbie' Question...

13. Simple quickdraw question