1. I think I'm close

I think this program is close to working.  The
problem is in the processAsyncMessage() procedure.
I'm really not sure of what I'm doing here, so if
someone could have a look and point me in the right
direction, I would be grateful.
Thanks...                   Andy


here is what I have so far...


include win32lib.ew
include srvsckip.ew

global sequence newsock,newIP,data
global integer MainWindow,data_display,Server,hWndMainWindow,iwork
global atom mySocket
global constant SM_ASYNC = #FFFF

iwork = WsockInit()
hWndMainWindow = getHandle(MainWindow)
Server = WsockListenAsync(23, hWndMainWindow, SM_ASYNC,or_all
({FD_READ,FD_ACCEPT,FD_CLOSE,FD_WRITE}))

global procedure processAsyncMessage(atom hWnd, atom arg1, atom arg2)
 integer action
 action=lo_word(arg2)
 if action = FD_ACCEPT then
  newsock = WsockAccept(Server)
      newIP = WsockGetSockName(newsock)
 end if
 if action=FD_READ then
  data = WsockReadData(arg1, 3)
  setText(data_display,data)
 end if

end procedure

data_display = create(16,"", MainWindow, 10,10 ,350,40, 0 )

global procedure onEventMainWindow(integer eventID, atom arg1, atom arg2)
 if eventID = SM_ASYNC then
      processAsyncMessage(hWndMainWindow,arg1,arg2)
   end if
end procedure

onEvent[MainWindow] = routine_id("onEventMainWindow")

WinMain(MainWindow,Normal)

new topic     » topic index » view message » categorize

2. Re: I think I'm close

Andy,

if you change the declaration of newsock from a sequence to an integer, it
runs just fine.

Looks like you're getting everything figured out!  Nice work.

Brian

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu