Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Mabry Socket/X control from vfp
Message
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00518847
Message ID:
00519393
Views:
16
Your code doesn't seem to connect the right way. If your Socket/X control's name is olecontrol1, your should start by doing something like this to connec:
with ThisForm
   .OleControl1.LocalAddress = "192.168.1.1" &&& your ip
   .OleControl1.LocalPort = 0
   .OleControl1.Create()
   *** if you connect by ip address, you should do then
    .OleControl1.RemoteNameAddrXlate = .F.
    .OleControl1.RemoteAddress = "212.155.99.148"  &&& other side's ip
   *** otherwise if you connect by name
    .OleControl1.RemoteNameAddrXlate = .T.
    .OleControl1.RemoteName = "www.eetasoft.ee"

   .OleControl1.RemotePort = 7
   .OleControl1.Blocking = .F.
   *** now set a connection timeout, let's say 5 seconds
   .OleControl1.ConnectTimeout = 5

   *** finally connect...
   .OleControl1.object.Connect()
endwith
Now, if you check ThisForm.OleControl1.State, it should really be 4 and then you can go on with the data transmissions.

Cheers,
Jaime

>I need to send and receive 00 bytes from tcp port.
>I have found that ms winsock control corrupts tcp packets containing 00
>bytes.
>
>So I desided to use Mabry Socket/X control.
>
>I made a simple test program. This program sends TCP packets to port 7
>and receives data from this port.
>
>I dropped Socket/X control to vfp 5 form and added the following code
>to form init :
>
>ACTIVATE SCREEN
>CLEAR
>ON SHUTDOWN QUIT
>THIS.olecontrol1.CREATE()
>DO WHILE THIS.olecontrol1.state!=3
> IF INKEY()=27
> RETURN .F.
> ENDIF
> ? THIS.olecontrol1.lasterrorstring, THIS.olecontrol1.state
> ENDDO
>
>THIS.olecontrol1.CONNECT( 'www.eetasoft.ee', 7 )
>
>DO WHILE THIS.olecontrol1.state!=4
> IF INKEY()=27
> RETURN .F.
> ENDIF
> ? THIS.olecontrol1.lasterrorstring, THIS.olecontrol1.state
> ENDDO
>
>cBuffer = REPLICATE( CHR(0), 100 )
>
>DO WHILE INKEY()!=27
> THIS.olecontrol1.sendto('www.eetasoft.ee', 7, m.cBuffer )
> THIS.olecontrol1.receivefrom('www.eetasoft.ee', 7 )
> ? THIS.olecontrol1.lasterrorstring, THIS.olecontrol1.state
> IF LEN(THIS.olecontrol1.receivebuffer)!=100 or ;
> THIS.olecontrol1.receivebuffer!=m.cBuffer
> ?? 'Error'
> ELSE
> ?? 'OK'
> ENDIF
> ENDDO
>
>RETURN .F.
>
>
>However, this code does not cause any internet access at all.
>.State after .create() remains 3
>
>Is it possible to use Mabry Socket/X with VFP ?
Why do programs stop working correctly as soon as you leave the Fox?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform