September 20, 2018
Hot Topics:

Communicating over a Network

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

As before, we need to check for a current connection:

If Winsock1.State Then
End If

Otherwise, listening is quite simple. Just use the Listen method of the Winsock control to do so:

Winsock1.LocalPort = 1008

You may have noticed the use of a port number above. This is possible because when creating comms apps you can use just about any port number. Below is a list of ports to avoid (or use for that matter) if you are creating a program because if you try and listen to the same port as a mail server, then one of the two fail.

  • SMTP: 25
  • POP: 110
  • FTP: 21
  • HTTP: 80
  • NNTP: 119
  • Telnet: 23
  • Gopher: 70
  • IRC: 6667

When it comes to sending text, things become very messy. Before starting, you need to sort out how your applications are going to communicate. For instance, assume you need to let the other end know what you are sending (text, file, etc). The best way to do this is to create a module that contains a load of constants that you can use to tell your program what's going on:

Public Const DATATEXT As Byte = 0

This way, every time you want to send a piece of text you send the DATATEXT constant first, then the size of it, and finally the actual content. Using this standard of operation, you can make your apps work together very nicely. At each point along the way you need to do two things: check for errors and wait until the current operation has been completed.

Page 5 of 7

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date