Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Richard Clarke
  Where is Richard Clarke?
 Crowcombe
 United Kingdom
 Richard Clarke
 To: dheeraj kumar
  Where is dheeraj kumar?
 chandigarh
 India
 dheeraj kumar
 Tags
Subject: RE: using winsock control
Thread ID: 209821 Message ID: 209835 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Active X Controls & OLE Automation
Date: Wednesday, December 31, 2008 2:14:53 PM         
   


> dear experts
>
> happy new year
>
>
> I want to receive data from telephone exchange using winsock control.. Exchange has an IP ie 192.168.1.50, Port 5100, I'd gone thru the detail & downloaded a small program of winsock, but not able to receive it... It works fine with Windows Hyper Terminal
>
> tcpserver is name of winsock control
> txtoutput is name of textbox in which i want to show data
>
> form Init Event
> --------------
> ThisForm.tcpServer.Object.LocalPort = 1001
> ThisForm.tcpServer.Object.Listen
>
>
> **************Winsock_DataArrival Event
> *** ActiveX Control Event ***
> LPARAMETERS bytestotal
>
> strData = SPACE(256) && Define string to pass to GetData
>
> This.Object.GetData(@strData)
> ThisForm.txtOutput.Value = strData
>
> *************winsock Connectionrequest Event
> *** ActiveX Control Event ***
> LPARAMETERS requestid
> #DEFINE sckClosed 0
> If This.Object.State <> sckClosed
> This.Object.Close
> ENDif
> *!* Accept the request with the requestID
> *!* parameter.
> This.Object.Accept(requestID)
>
> Kindly help
>
>
> kumardheeraj

Hello,

I have done some basic w3ork with winsock and think that if you make the following additions you should be able to communicate.

In the init you need to set the remote host and port

thisform.tcpserver.object.remotehost = "192.168.1.50"
thisform.tcpserver.object.remoteport = 5100


you then need to connect to the remote host.

thisform.tcpserver.object.connect()


you can then test to see if you have connected, maybe via a button on your form

lnConnectionStatus = thisform.tcpserver.object.state
*!* 0 sckClosed connection closed
*!* 1 sckOpen open
*!* 2 sckListening listening for incoming connections
*!* 3 sckConnectionPending connection pending
*!* 4 sckResolvingHost resolving remote host name
*!* 5 sckHostResolved remote host name successfully resolved
*!* 6 sckConnecting connecting to remote host
*!* 7 sckConnected connected to remote host
*!* 8 sckClosing connection is closing
*!* 9 sckError error occured



Regards

Richard

ENTIRE THREAD

using winsock control Posted by dheeraj kumar @ 12/31/2008 12:43:22 PM
RE: using winsock control Posted by Richard Clarke @ 12/31/2008 2:14:53 PM