Communication Over Networks Los Angeles CA

Have you ever wanted to send a simple string of text over your local LAN? Or maybe you have wanted to send and receive pictures and files with a friend from the other side of the world. Whatever your needs, the Winsock control can help out.

Local Companies

Moyea Software
92295612365
Hot building, ring street
LA, CA
Interneer Inc.
8005586832 x85
6101 W. Centinela Ave.
Culver City, CA
Cornerstone Concepts Inc
818-247-3909
600 W Broadway
Glendale, CA
Greene Computer Corporation
(818) 956-4961
200 S. Louise Street
Glendale, CA
Corticalx Inc Software Solutions & Technology
818-500-0881
425 E Colorado St
Glendale, CA
Alphatier Systems
818-409-8920
517 Griswold St
Glendale, CA
TimeTECH - Customizable Time and Attendance / Workforce Management Solutions
905-677-7009
7420 Airport Rd 203
Mississauga, CA
Hutchinson & Bloodgood, LLP
(818) 637-5000
101 N. Brand Blvd. #1600
Glendale, CA
Telsoft Solutions
818-545-8680
100 N Brand Blvd
Glendale, CA
Abraxas Technologies Inc
818-502-9100
450 N Brand Blvd
Glendale, CA

provided by: 
Originally published at Internet.com


Have you ever wanted to send a simple string of text over your local LAN? Or maybe you have wanted to send and receive pictures and files with a friend from the other side of the world. Whatever your needs, the Winsock control can help out.

In this article you will learn the basics of the Winsock control, and how you can use it to transfer data and information over a network and the Internet.

The Winsock control does not provide us with many properties, but it gives us many events and methods to play with. The most important properties are: * RemoteHost - The IP/Machine name of the remote machine * RemotePort - The remote port number that the remote machine is listening to * LocalPort - The local port number to listen to

As you can see, these three properties are quite important. When connecting, you will need to set the RemoteHost and RemotePort, but when you are listening you will only need to set the local port property.

Like the Internet Transfer Control, the Winsock control provides us with some constants. These include ErrorConstants, StateConstants and ProtocolConstants. To see a list of them, click View, Object Browser (or Press F2). From the drop down combo, select MSWinsockLib. You can now see the enumerations of constants. For this article, we will mainly be using the default TCP (Transmission Control Protocol).

Connecting to a computer is not as easy as just calling the Connect method and specifying a remote IP and port. You need to do a fair amount of 'handshaking', which is making sure that the other computer is still there and wanting to connect.

First, before starting a connection, it's always good practice to close any current operations before you start to ensure that the Winsock control is available: Winsock1.Close While Winsock1.State DoEvents Wend

See the use of the While Wend loop? That is to make sure that you don't start trying to do something while the winsock control is still finishing an operation.

When connecting, you will also need to check for errors: If Err Then Msgbox Err.Number, Err.Description Err = 0 End If

As done before, you need to make sure that you don't start doing tasks before the control is ready: While Winsock1.Waiting DoEvents Wend

Most of the code you have seen now forms the bulk of a Connect method. You will now learn about the Listen method. The Listen method is what the receiving computer must do to hear Connect methods.

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.

The best way to handle errors is to use events.

In Visual Basic, you can create your own events. An example event might be when you click on a button: Private Sub Command1_Click()

You call or 'raise' events using the RaiseEvent method. This method accepts one parameter, which is one of the events declared. You declare an event like this: Public Event TextSent(TextContent As String)

The event procedure for this event will look like this: Private Sub MyModule_TextSent(TextContent As String)

The last thing you will discover in this article are operation time outs. When using the Winsock control, or in fact any Internet comms control, you need to be able to detect a time out. This occurs, for instance, when an application you are talking to stops responding while you are communicating with it. If you didn't watch for a time out, then you program would just sit around waiting for the other program to respond. The easiest way to watch for these is by using a timer control.

By setting the Interval property to a reasonable length, for instance 30000, then you can detect time outs. Again, use events to tell the user what's going on. You need to do this in the timers Timer event: Private Sub Timer1_Timer() RaiseEvent TimeOut End Sub

To finish, here are some quick guidelines for specifying addresses: 1. Where possible use an IP address (127.0.0.1) instead of computer names because the Winsock control has to resolve a host name to an IP address - this takes some time. 2. If you connect to the net over a dial up connection, you can still get this to work. When you have logged on, use the Winsock's LocalIP method to return to current IP address. This way you can send it to your friend and he/she can connect to you.

Author: Sam Huggill

Read article at Internet.com site

Featured Local Company

Moyea Software

92295612365
Hot building, ring street
LA, CA

Related Local Events
Automation Technology Expo West (ATX West)
Dates: 2/9/2010 - 2/11/2010
Location: Anaheim Convention Center
Anaheim, CA
View Details

SOLAR POWER - Exhibition and Conference
Dates: 10/12/2010 - 10/14/2010
Location: Los Angeles Convention & Exhibition Center
Los Angeles, CA
View Details

REAL-TIME & EMBEDDED COMPUTING CONFERENCE - LONG BEACH 2009
Dates: 10/1/2009 - 10/1/2009
Location: Marriott Long Beach
Long Beach, CA
View Details

2009 IEEE Petroleum and Chemical Industry Technical Conference (PCIC 2009)
Dates: 9/14/2009 - 9/16/2009
Location:
Anaheim, CA
View Details

Medical Design & Manufacturing - Trade
Dates: 6/9/2009 - 6/11/2009
Location: CANON COMMUNICATIONS LLC
Los Angeles, CA
View Details