>** form.init method >ACTIVATE SCREEN >CLEAR >ON SHUTDOWN QUIT >SET TALK OFF >SET ECHO OFF > >with ThisForm > .OleControl1.LocalAddress = "194.106.108.233" &&& your ip > .OleControl1.LocalPort = 0 > .OleControl1.Create() > .OleControl1.RemoteNameAddrXlate = .T. > .OleControl1.RemoteName = "pepe.online.ee" > .OleControl1.RemotePort = 7 > .OleControl1.Blocking = .F. > .OleControl1.ConnectTimeout = 5 > .OleControl1.object.Connect() >endwith > >DO WHILE THIS.olecontrol1.state!=4 > IF INKEY(0.5)=27 > RETURN .F. > ENDIF > ? 'Connecting', THIS.olecontrol1.lasterrorstring >ENDDO > >m.cBuffer = REPLICATE( CHR(0), 100 ) >local dummyWait > >DO WHILE INKEY(.5)!=27 and THIS.olecontrol1.state=4 > This.OleControl1.SendBuffer = m.CBuffer &&& you don't need CREATEBINARY > THIS.OleControl1.object.Send() > dummyWait = inkey(3) &&& waits 3 seconds to give some time to the send > CStr = '' > DO WHILE INKEY(.5)!=27 and THIS.olecontrol1.state=4 AND EMPTY(cStr) > THIS.OleControl1.object.receive() > cStr = this.olecontrol1.receivebuffer > ? THIS.olecontrol1.lasterrorstring > ENDDO > > ?'Received', len(cStr), cStr > IF cStr!=m.cBuffer > ?? 'Error' > ELSE > ?? 'OK' > ENDIF > ENDDO >RETURN .F. >>
>>** form.init method >>ACTIVATE SCREEN >>CLEAR >>ON SHUTDOWN QUIT >>SET TALK OFF >>SET ECHO OFF >> >>with ThisForm >> .OleControl1.LocalAddress = "194.106.108.233" &&& your ip >> .OleControl1.LocalPort = 0 >> .OleControl1.Create() >> .OleControl1.RemoteNameAddrXlate = .T. >> .OleControl1.RemoteName = "pepe.online.ee" >> .OleControl1.RemotePort = 7 >> .OleControl1.Blocking = .F. >> .OleControl1.ConnectTimeout = 5 >> .OleControl1.object.Connect() >>endwith >> >>DO WHILE THIS.olecontrol1.state!=4 >> IF INKEY(0.5)=27 >> RETURN .F. >> ENDIF >> ? 'Connecting', THIS.olecontrol1.lasterrorstring >> ENDDO >> >>cBuffer = REPLICATE( CHR(0), 100 ) >> >>DO WHILE INKEY(.5)!=27 and THIS.olecontrol1.state=4 >> THIS.olecontrol1.send( CREATEBINARY(m.cBuffer) ) >> CStr = '' >> * ?????????????????????????????????????????????????? >> * The following loop will run infinitely. Why ? >> DO WHILE INKEY(.5)!=27 and THIS.olecontrol1.state=4 AND EMPTY(cStr) >> THIS.olecontrol1.receive(1) >> cStr = this.olecontrol1.receivebuffer >> ? THIS.olecontrol1.lasterrorstring >> ENDDO >> >> ?'Received', len(cStr), cStr >> IF cStr!=m.cBuffer >> ?? 'Error' >> ELSE >> ?? 'OK' >> ENDIF >> ENDDO >>RETURN .F. >>>>
>>>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.