dcsimg
December 5, 2016
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
  Winsock1.Close
End If

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

Winsock1.LocalPort = 1008
Winsock1.Listen

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.

Sitemap | Contact Us

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