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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock SendData Issue

Status
Not open for further replies.

cmahon

Programmer
Sep 25, 2003
27
0
0
IE
Hi All

I am having an issue with a Winsock control where I have 2 pcs on the same network. I establish a connection from the first pc to the second pc with the following code:

tcpClient.RemoteHost = "CNNNNNN"
tcpClient.RemotePort = 11542
tcpClient.Connect

I then check the value of the tcpClient.State which is 7. I then call the SendData method

tcpClient.SendData strLocation

The Second PC should then receive the string and display a tif file on it's screen (the string value being passed is the Location of the Tif on the network). This, however, is not working - the SendData call is doing nothing, it doesn't raise an error but it also doesn't send the Location of the Tif to the Second PC.

Code on First (Sender) PC

With frmNewScans
.tcpClient.Close
.tcpClient.RemoteHost = strPCtoConnectTo
.tcpClient.RemotePort = 11542
.tcpClient.Connect
End With

In a Click Event I then have

tcpClient.SendData (CStr(myFile.Path))
tcpClient.Close

In the Second (Receiver) PC Code:

In ConnectionRequest

tcpDisplay.Accept RequestID

In the DataArrival Sub I have

tcpFaxServer.GetData strLocation

Is there anything else I should be looking out for?

Thanks in advance for any tips/suggestions

cmahon


 
myFile.Path? Are you using the FSO and Scripting Runtime objects or something? Just curious.

You really aren't meant to buzz the State property of the Winsock control, that's why there is a Connect event.

Before doing a subsequent client Connect with a previously used Winsock control be sure to set the LocalPort property back to 0.

It is flawed logic to expect a given GetData() call to retrieve everything you expect in one gulp. You are only guaranteed one byte (character) for each DataArrival event, though when "the planets align correctly" you can get lucky and get everything you expect and no more. See item #20 in The Lame List.

Is the DataArrival event firing at all in your server program? If so, what is it retrieving?
 
Hi,

Thanks for your response. The DataArrival event is not firing at all in the server program. Nothing at all is being transferred. I have added code to the Error events of both the Client and Server winsock controls but nothing is being fired there either.

As a test I used the VB help files winsock sample program and ran it on both of the machines, surprisingly it has run exactly as expected. Using this program I can send data from one machine to another. I then used this program as a basis for my main program but again it didn't work.

Thanks

cmahon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top