Yes is a normal error For use nonblocking socket... Windows doc api explain itDaniel Garcia-Gil wrote: With a nonblocking socket, the connection attempt cannot be completed immediately. In this case, connect will return SOCKET_ERROR, and WSAGetLastError will return WSAEWOULDBLOCK. ( you can call after connect, will see )
Tsocket Bug
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
Re: Tsocket Bug
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Re: Tsocket Bug
Daniel,
ıs it possible to set a timeout to give alert client that the connection has not been established when there is no message "ok"
Thanks,
ıs it possible to set a timeout to give alert client that the connection has not been established when there is no message "ok"
Thanks,
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
Re: Tsocket Bug
Hello
you can use a timer to call Connect() again if you got not a "ok", with max Retry options
1- initiate Retry variable
2- open timer
3- connect
4- if you get "ok" deactivate the timer, else try connect again until max retry is take (deactivate timer )
is only a idea
you can use a timer to call Connect() again if you got not a "ok", with max Retry options
1- initiate Retry variable
2- open timer
3- connect
4- if you get "ok" deactivate the timer, else try connect again until max retry is take (deactivate timer )
is only a idea
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Re: Tsocket Bug
Hi Daniel,
This is my last SockCli.prg.
This is my last SockCli.prg.
Code: Select all
// Socket server connection sample
#include "FiveWin.ch"
#define nWaitTime 10000
static oWnd, oSocket, oTimer, nTry
function Main()
local oBar
DEFINE WINDOW oWnd TITLE "Client socket"
DEFINE BUTTONBAR oBar OF oWnd _3D
DEFINE BUTTON OF oBar ACTION Client() TOOLTIP "Connect"
DEFINE BUTTON OF oBar ;
ACTION oSocket:SendData( "MSG This is a test" ) ;
TOOLTIP "Send data"
DEFINE BUTTON OF oBar ;
ACTION SendFile() TOOLTIP "Send file"
ACTIVATE WINDOW oWnd
return nil
function Client()
if oSocket != NIL
oSocket:End()
endif
oSocket = TSocket():New( 5000 )
if oTimer != NIL
oTimer:End()
endif
nTry := 1
oSocket:bRead = { | oSocket | HandleRecived( oSocket, oWnd ) }
// Never use a MsgInfo() here because it hangs Windows!!!
oSocket:bConnect = { || oWnd:SetText( "Socked Opened!" ) }
oSocket:bClose = { || MsgInfo( "Server has closed!" ) }
Timer_Connect()
Define Timer oTimer Interval nWaitTime Action Timer_Connect() OF oWnd
Activate Timer oTimer
return nil
function Timer_Connect()
IF nTry<4
oWnd:SetText("Connection Try : "+ALLTRIM(STR(nTry)))
oSocket:Connect( "127.0.0.1" )
nTry++
ELSE
oTimer:End()
oSocket:End()
oWnd:SetText( "Socket Closed" )
MsgInfo("Connection can NOT be ESTABLISHED")
ENDIF
return
function SendFile()
local cFileName := cGetFile( "*.*", "Select a file to send by Internet" )
if ! Empty( cFileName ) .and. File( cFileName )
oSocket:SendData( "SENDFILE " + cFileName( cFileName ) )
oSocket:SendFile( cFileName )
MsgInfo( "File sent" )
endif
return nil
function HandleRecived( oSocket, oWnd )
local cData := oSocket:GetData()
if cData = "ok"
oWnd:SetText( "Connected!!" )
oTimer:End()
else
MsgInfo( cData )
endif
return nil
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
Re: Tsocket Bug
Hello
what's mean? all is working fine now?
what's mean? all is working fine now?
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Re: Tsocket Bug
Yes. I also think to use cargo if its really connected.
Thank you very much.
Thank you very much.
Code: Select all
function HandleRecived( oSocket, oWnd )
local cData := oSocket:GetData()
if cData = "ok"
oWnd:SetText( "Connected!!" )
oTimer:End()
oSocket:cargo:=.t. // it is connected.
else
MsgInfo( cData )
endif
return nil
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12