Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can winsock control handle more than one remote ip?

Status
Not open for further replies.

bmez

Programmer
Apr 19, 2002
3
0
0
US
I'm using the winsock control, which requires defining a specific winsockclient.remotehost ip address. This is for testing a small network, which will require several other ip addresses.

Is there a dhcp server which can be used with vb to assign the ip addresses? And can more than one remote ip address be assigned to a winsock control?
 
The remotehost property is the ip address of the machine you're trying to connect to, not the ip address of a network adapter on your machine.

Also - One conversation, one Winsock control. If you want multiple conversations, you'll have to either code at the API level, or use multiple controls.

Chip H.
 
Very hard to discuss this without a clearer picture of what you wish to accomplish. Let's imagine you wanted to make a simple chat server though, a common sample scenario for learning Winsock server programming.

The basic idea is to use a Winsock Control array. You listen for connections on one Control, and when ConnectionRequest events arrive, you assign the incoming connection to a unique Winsock Control instance from your array. This is pretty well documented in the VB help files, but many people find the information given here pretty opaque without an intact example. The web is crawling with these however ;-) so you might try a search for something like "VB chat server sample."

Normally the RemoteHost and RemoteHostIP properties might be interrogated by a Winsock server, but only set by a client in order to say what server you want to connect to. A typical Winsock client is pretty easy to construct, and there are a plethora of samples of these about as well.

Perhaps I am missing your point however.

You have "a small network." Doesn't each machine already HAVE an IP address? Why are you looking for a DHCP server? If your DHCP server assigns dynamic addresses, you won't be able to connect by IP address anyhow - the addresses are "dynamic" (thus the name) and subject to change over time. Most likely you will connect using RemoteHost instead, and on most Windows networks you'll be able to use the machine names in your workgroup or domain, without mucking with HOSTS files or anything of the kind.

In case I am STILL way off-base above, and you really want a DHCP server, there are two easy choices:

* Run Internet Connection Sharing (ICS) or a 3rd-party alternative on one Windows machine. ICS is a DHCP server.

* Buy a low-cost "home cable/DSL router" that can act as a DHCP server. Many wireless access points have this functionality as well, if you are using a wireless LAN.


If we're still missing your point, please try clarifying your question.
 
Thanks for the replies.

To clarifiy the application further, I am running a network where each node consists of an embedded micocontroller which is dynamically assigned an ip address from a dhcp server (Linksys). The purpose of the vb application is to send a data packet to one of the network nodes through a winsock control through the winsockclient.remotehost.

What I'm doing right now is pretty crude, I'm just reading the dhcp table on the pc which is attached to that pc's nic card. I'm then manually modifying my single winsock control winsockclient.remotehost ip address. That test code was ok when having a node or two on the network, but the number of nodes it must handle will be up to 16.

What would be better, is to have the the ip addresses in an array as you suggested. I'm not as familiar with the winsock stuff, as the embedded code in my system, but I think I follow some of your suggestions.

I welcome any more suggestions - or details you might have.

Thanks - Bob
 
If you want to stay along the same lines with a winsock control. Put the first control on your form and set it's index property to 0. that part is very important for the rest

When you search through to get the IP addy's add the following. Here I will assume that you are reading the file and loading to an array etc.
[tt]
Open FilName for Output as #FileNum

Do While not EOF(#FileNum)
intCount = intCount + 1
strLine = LineInput #FileNum
Load WinSock1(intCount)
WinSock1(intCount).RemoteHost = strLine
Loop
[/tt]
There is of course a lot more code involved, but that will get you started. Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top