Library code snippets

Create a messaging server using winsock

In real world situations, you are usually faced with such situations when you are asked to develop an application for the Internet and Winsock is one of the best tools available in the market which facilitates the creation of Internet applications. You can use this application to send instant messages to your main server(WMS application), no matter where the server is situated, until it is connected to the Internet your web site would be able to access the server.

Something about this program!!!!

In the zip file you will find the following:

1. Source code of the WMS server
2. WMS server EXE file
3. Web application to test the application

Running the Application

1. Copy the complete site to your computer and create a virtual directory in IIS which should point towards the folder where you would unzip the site or where the site is located.

2. The site has only one page,
3. Run the EXE server file and than run the web site. Enter a valid IP Address, write the IP address of your machine if the WMS server is located on your machine else enter the IP of the remote PC where the Server is installed. Enter the message in the message box and press "Send Message". Your message would be sent to the server. That's it!!!!!!!!!

Purpose of this application??

In real world situations, you are usually faced with such situations when you are asked to develop an application for the Internet and Winsock is one of the best tools available in the market which facilitates the creation of Internet applications. You can use this application to send instant messages to your main server(WMS application), no matter where the server is situated, until it is connected to the Internet your web site would be able to access the server. You will have to keep the server (WMS Application) running all the time to see any incoming messages, you can build upon this application and extend its usage and importance, you can enhance its performance by inducting new features, study the Winsock control and you can create a component of your own and you wont need any third party support for your users. The main logic is that you create one server application in VB and place that application on the machine which is connected to the Internet and you create another web application which can be located anywhere and the users accessing your site would be able to send you instant messages, those messages would appear in your WMS server application. Basically, its a kind of client server application, both applications are using the sockets to talk to each other.

Note
To run the application, you will have to install TCP sockets on your machine, download the w3 socket component from http://tech.dimac.net, this is a self extracting file and will install the sockets on your machine with a single click.

Potential Problems

You might have to confront the problem if the port is not available on your machine, I have hardcoded the port number "5500" in both WMS Server and in ASP page, you will have to change both the port numbers, try 1007. Stop the server, make the required change and compile the server again. Run the server EXE file and than run the site again, it will work!!!!

If the 5500 is port is not free on your machine, then open the server project and locate the line:

Winsock1.port = 5500

Change this line to:

Winsock1.port = 1007

Similarly open the ASP page and change the port number to 1007.

 

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Create a messaging server using winsock.

  2. 16 Aug 2002 at 07:57

    Mr Ahmed,
    I am right now developing a chat software and I really can't understand what kind of mechanism you have used in your application to retrieve the remotehostIP?Plz Explain

Leave a comment

Sign in or Join us (it's free).

S.S. Ahmed S.S. Ahmed is a senior IT Professional and works for a web and software development firm. Ahmed is a Microsoft Office SharePoint Server MVP. Ahmed specializes in creating database driven dynamic we...

Related discussion

Related podcasts

  • Visual Studio Talk Show (en français): Christian Beauclair

    Published 1 year ago, running time 0h51m

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss... de, il, christian, vb6

Want to stay in touch with what's going on? Follow us on twitter or Facebook!