Discussion:
ActiveX MSWinsck string problem
(too old to reply)
Francis
2008-10-01 13:48:48 UTC
Permalink
hello,
I attempt to use Microsoft Winsock Control with my dBasePlus 2.61.5
this activex seems work fine except when I getdata in the ACTIVEXSer_DataArrival event.
the bytestotal parameter give the good length (18).
the getdata(receivedata) do not fill the receivedata string.
I send "-test test test-"+ chr(13) + chr(10) with PUSHBUTTONSEND.onClik
This is the sample:
** END HEADER -- do not remove this line
//
// Generated on 25/09/2008
//
parameter bModal
local f
f = new WinSockForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class WinSockForm of FORM
with (this)
canClose = class::FORM_CANCLOSE
onOpen = class::FORM_ONOPEN
height = 11.0
left = 34.7143
top = 6.4545
width = 30.0
text = "MsWinSock"
mdi = false
sizeable = false
mousePointer = 1 // Arrow
maximize = false
endwith

this.PUSHBUTTONSEND = new PUSHBUTTON(this)
with (this.PUSHBUTTONSEND)
onClick = class::PUSHBUTTONSEND_ONCLICK
height = 1.2
left = 2.0
top = 0.15
width = 4.0
text = ""
speedBar = true
upBitmap = "RESOURCE #20"
disabledBitmap = "RESOURCE #21"
speedTip = "Start"
group = true
endwith

this.BTNEND1 = new PUSHBUTTON(this)
with (this.BTNEND1)
onClick = {;Form.Close()}
height = 1.2
left = 24.0
top = 0.15
width = 4.0
text = ""
speedBar = true
upBitmap = "RESOURCE #1005"
disabledBitmap = "RESOURCE #1006"
speedTip = "Quitter"
group = true
endwith

this.ACTIVEXSER = new ACTIVEX(this)
with (this.ACTIVEXSER)
height = 1.2
left = 8.0
top = 0.15
width = 4.0
borderStyle = 3 // None
license = "2c49f800-c2dd-11cf-9ad6-0080c7e7b78d"
state = "DCFEEFCDBJBBBBBBPGBDBBBBPGBDBBBBKDOJJODFBBBBBHBBBBBBBBBBBBBBBBBBBBBBBBBBGJCMBBBB"
classId = "{248DD896-BB45-11CF-9ABC-0080C7E7B78D}"
endwith

with (this.ACTIVEXSER.nativeObject)
ConnectionRequest = class::ACTIVEXSER_CONNECTIONREQUEST
DataArrival = class::ACTIVEXSER_DATAARRIVAL
endwith

this.ACTIVEXCLI = new ACTIVEX(this)
with (this.ACTIVEXCLI)
height = 1.2
left = 13.0
top = 0.15
width = 4.0
borderStyle = 3 // None
license = "2c49f800-c2dd-11cf-9ad6-0080c7e7b78d"
state = "DCFEEFCDBJBBBBBBPGBDBBBBPGBDBBBBKDOJJODFBBBBBHBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
classId = "{248DD896-BB45-11CF-9ABC-0080C7E7B78D}"
endwith


function form_onOpen
clear
form.TcpSer = this.activexSer.nativeObject
form.TcpSer.protocol = 0 && 0 TCP, 1 UDP
form.TcpSer.localPort = 7000
form.TcpSer.listen()
? "Listen Ser:", form.TcpSer.state

form.TcpCli = this.activexCli.nativeObject
form.TcpCli.protocol = 0 && 0 TCP, 1 UDP
form.TcpCli.remoteHost = form.TcpSer.localIp &&"192.168.1.45"
form.TcpCli.remotePort = 7000
form.TcpCli.connect()
? "Connect Cli:", form.TcpCli.state
return

function form_canClose
form.TcpSer.close()
form.TcpCli.close()
return true

function PUSHBUTTONSEND_onClick
local sData
? "Status Cli:", form.TcpCli.state
if form.TcpCli.state = 7
sData = "-test test test-"+ chr(13) + chr(10)
form.TcpCli.sendData(sData)
endif
//NETSTAT -a to see TCP ports
return

function ACTIVEXSer_ConnectionRequest(requestID)
if form.TcpCli.state = 7
if this.state > 0
this.close()
endif
this.accept(requestID)
endif
return

function ACTIVEXSer_DataArrival(bytesTotal)
? program(), str(bytesTotal,4)
local receiveData
receiveData = replicate("0", bytesTotal)
this.getData(receiveData)
? program(), "-"+ receiveData +"-"
return

endclass
Marc VdB
2008-10-02 10:12:28 UTC
Permalink
Hi Francis
Post by Francis
this activex seems work fine except when I getdata in the ACTIVEXSer_DataArrival event.
the bytestotal parameter give the good length (18).
the getdata(receivedata) do not fill the receivedata string.
On my machine the dataarrival event doesn't fire at all...

How do you know the meaning of the state property ? I guess, that the
client did not connect to the server, but can' be sure, because i can't
interpret te state..

CU, Marc
Francis
2008-10-02 15:34:07 UTC
Permalink
Marc,

this is the doc :
http://msdn.microsoft.com/en-us/library/aa733709(VS.60).aspx

you need to register the ocx :
Start Execute RegSvr32 C:\Windows\System32\mswinsck.ocx

and add this activex in dbase :
design form -> file -> set up activex components
add -> Microsoft Winsock Control, version 6.0 on the right side, ok
now you can see this activex in the activex selection of component palette

At this time I try to test the same process with SocketWrench version 3.6

Francis
Post by Marc VdB
Hi Francis
On my machine the dataarrival event doesn't fire at all...
How do you know the meaning of the state property ? I guess, that the
client did not connect to the server, but can' be sure, because i can't
interpret te state..
CU, Marc
Mervyn Bick
2008-10-02 16:11:17 UTC
Permalink
Post by Francis
hello,
I attempt to use Microsoft Winsock Control with my dBasePlus 2.61.5
this activex seems work fine except when I getdata in the
ACTIVEXSer_DataArrival event.
the bytestotal parameter give the good length (18).
the getdata(receivedata) do not fill the receivedata string.
I send "-test test test-"+ chr(13) + chr(10) with PUSHBUTTONSEND.onClik
function PUSHBUTTONSEND_onClick
local sData
? "Status Cli:", form.TcpCli.state
This shows the state is 6 which means the test in the next line fails and
form.TcpCli.sendData(sData) is, therefore, not actioned.
Post by Francis
if form.TcpCli.state = 7
sData = "-test test test-"+ chr(13) + chr(10)
form.TcpCli.sendData(sData)
endif
//NETSTAT -a to see TCP ports
return
Your form ran a couple of times and then I started getting "not
registered" messages. I wasn't able to register the OCX so I gave up for
the meantime.

Mervyn.
Loading...