Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help needed on CSocket, please.

2 views
Skip to first unread message

youngs...@my-deja.com

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
Hi,

I've just started CSocket. I'm writing a CSocket server and a client.
When the client sends some data, the server will receive and process
the received data.

This works when the client sends for the first time. But the second
try fails. Could you please help me what's wrong with the codes below ?

Any comment would be appreciated.

Young Suk Park

-----------------------------------------
METHOD Init( oParent ) CLASS ClientWindow

SUPER:Init( oParent )

SELF:oSocket := CSocket{ SOCK_STREAM }
SELF:oSocket:Connect( cServerIPAddress, nServerPort )
RETURN SELF
-----------------------------------------
METHOD Send( cData ) CLASS ClientWindow

SELF:oSocket:SendLine( cData )
-----------------------------------------
METHOD Init( oParent ) CLASS ServerWindow

SUPER:Init( oParent )

SELF:oSocket := CSocket{ SOCK_STREAM }
SELF:oSocket:Bind( nServerPort, cServerIPAddress, AF_INet )

SELF:PrepareThread()
RETURN SELF
-----------------------------------------
METHOD PrepareThread() CLASS ServerWindow

LOCAL dwThreadID AS DWORD

SELF:hThread := CreateVOThread( NULL_PTR, 0, @ListenProcess(), ;
PTR( _CAST, SELF ), 0, @dwThreadId )
-----------------------------------------------------------
FUNCTION ListenProcess( dwParam AS DWORD ) AS VOID PASCAL

LOCAL oWin AS ServerWindow
LOCAL oSockMsg AS CSocket

oWin := OBJECT( _CAST, dwParam )

oWin:Socket:Listen( 5 )

DO WHILE SomeCondition
oSockMsg := oWin:Socket:accept()
IF oSockMsg != NULL_OBJECT
oWin:DoSomeProcess( oSockMsg )
oSockMsg:DisConnect()
ENDIF
ENDDO


Sent via Deja.com http://www.deja.com/
Before you buy.

Geoff Schaller

unread,
Oct 20, 2000, 3:00:00 AM10/20/00
to
YSP,

This is not a direct answer to your question but have you tried the
echo-server and client demo app in the gallery? I found it quite
instructive - although I had to muck around a bit to get it to work
properly.

Geoff


<youngs...@my-deja.com> wrote in message
news:8snf21$dj2$1...@nnrp1.deja.com...

0 new messages