I just started work on some netcode and all was going ok (fairly) till i got Num3 to compile me the test code into an exe. Then s... hit the fan...
If run both the server code and the client test codefrom inside PB, all goes as planed.
If i run the server from PB and the compiled client test exe, all is fine also. BUT, if i comment out the last line of the client test, it doesnt. Data doesnt get sent.
I dunno this is a PB thing, windows thing or if it only happens on a local machine (ie no delay in comms), but its weird that the disconnect msg arrives at server before the data taht was sent, when the data was actually sent before the app quit.....
Any comments on this? Oh, and here is teh code... Its a bit sloppy, but works

-----------
server code
-----------
Procedure conout(tstring$)
Shared opcon
If opcon
PrintN(tstring$)
EndIf
EndProcedure
;Open a console so we can track server progress..... no console, no tracking
opcon=OpenConsole()
initnet=InitNetwork()
If initnet=0
mresult=MessageRequester("Warning","Sorry, no network, shutting down!",#PB_MessageRequester_Ok)
End
EndIf
opennetserver=CreateNetworkServer(9999)
If opennetserver=0
mresult=MessageRequester("Warning","Sorry, couldnt start server!",#PB_MessageRequester_Ok)
End
EndIf
If opcon
PrintN("Ok, server started!")
EndIf
;
;
;
maxclients=250
connectedclients=0
authedclients=0
Structure clientconn
cid.l
cauth.b
cuname$
cpassw$
csig1.b[32]
csig2.b[32]
EndStructure
NewList cconns.clientconn()
Dim buffermem.b(512) ; maxpacket size anyway
Procedure NewCon()
Shared connectedclients, maxclients
conout("NewCon()")
ncid=NetworkClientID()
;Oh boy, another one fell 4 it..... evil grin....
conout("Got a live one here!")
connectedclients+1
;Did we go over limit?
If connectedclients>maxclients
;Damn, we did. Lest scan and see if we can find/kick unauthed clients
;We couldnt, so, drop this one... sorry dude
CloseNetworkConnection(ncid)
connectedclients-1
conout("Droped conn... too many already")
Else
;Were still ok.... lets add this one
AddElement(cconns.clientconn())
cconns.clientconn()\cid=ncid
;Lets hope he auths
EndIf
EndProcedure
Procedure ReceiveDataFromNetwork()
Shared connectedclients
conout("ReceiveDataFromNetwork()")
ncid=NetworkClientID()
conout("data from "+Str(ncid))
;Find who wants our attention. Try last user 1st, may be him again
If ncid=cconns.clientconn()\cid
;Lucky.....
Else
For c.l=1 To CountList(cconns.clientconn())
SelectElement(cconns.clientconn(),c.l)
If cconns.clientconn()\cid=ncid
toselect=c.l
EndIf
Next
;Gotcha
SelectElement(cconns.clientconn(),toselect)
EndIf
;Is it an auth?
conout("doing auth")
If cconns.clientconn()\cauth=0
;Yup, it is
authbytes= ReceiveNetworkData(ncid, @buffermem.b(0), 512)
Debug authbytes
If authbytes16
;Oh oh, hes not a real one, now is he.....KILL the conn NOW! ... and free resources

CloseNetworkConnection(ncid)
DeleteElement(cconns.clientconn())
connectedclients-1
conout("Kicked a faker!!! Bad uname/passw length!!!")
Else
;Ok, do the 1st auth stage
clientfname$=""
For c.l=0 To 15
clientfname$=clientfname$+chr$(buffermem.b(c.l))
Next
opfile=OpenFile(0,clientfname$+".sig")
If Lof()=0
;No such client.... drop him and cleanup
CloseNetworkConnection(ncid)
DeleteElement(cconns.clientconn())
connectedclients-1
CloseFile(0)
DeleteFile(clientfname$+".sig")
conout("Droped "+clientfname$+" No such user!")
EndIf
EndIf
Else
EndIf
EndProcedure
Procedure ClientDropped()
Shared connectedclients
conout("ClientDropped()")
ncid=NetworkClientID()
; Damn, he got away..... Find who quit. Try last user 1st, may be him again
If ncid=cconns.clientconn()\cid
;Lucky.....
Else
For c.l=1 To CountList(cconns.clientconn())
SelectElement(cconns.clientconn(),c.l)
If cconns.clientconn()\cid=ncid
tokill=c.l
EndIf
Next
EndIf
;Cleanup after him
SelectElement(cconns.clientconn(),tokill)
DeleteElement(cconns.clientconn())
connectedclients-1
conout("Another one blew town.....")
EndProcedure
;
;
;
Repeat
netevent=NetworkServerEvent()
Select netevent
Case 0
Delay(1) ; Dont busy loop, it sucks
Case 1
NewCon()
Case 2
ReceiveDataFromNetwork()
Case 4
ClientDropped()
EndSelect
Until closeserver=1
;
;
;
CloseNetworkServer()
mresult=MessageRequester("Warning","Ok, server stoped!",#PB_MessageRequester_Ok)
-----------
client code
-----------
;Open a console so we can track server progress..... no console, no tracking
opcon=OpenConsole()
initnet=InitNetwork()
If initnet=0
mresult=MessageRequester("Warning","Sorry, no network, shutting down!",#PB_MessageRequester_Ok)
End
EndIf
Procedure connsendstring(tstring$)
Shared cid
SendNetworkData(cid,@tstring$,Len(tstring$))
EndProcedure
;
; bad conn 1 bad user name
;
cid=OpenNetworkConnection("192.168.0.1",9999)
If cid
If opcon
PrintN("Ok, found server.")
EndIf
connsendstring("rheshadeshadowsn")
;by now he should have dropped me

Else
mresult=MessageRequester("Warning","Funny, no server found... is it running????",#PB_MessageRequester_Ok)
End
EndIf
;
; bad conn 2 uname too big
;
cid=OpenNetworkConnection("192.168.0.1",9999)
If cid
If opcon
PrintN("Ok, found server.")
EndIf
connsendstring("theshadeshadowsnn")
;by now he should have dropped me

Else
mresult=MessageRequester("Warning","Funny, no server found... is it running????",#PB_MessageRequester_Ok)
End
EndIf
;
; bad conn 3 uname too small
;
cid=OpenNetworkConnection("192.168.0.1",9999)
If cid
If opcon
PrintN("Ok, found server.")
EndIf
connsendstring("theshadeshadows")
;by now he should have dropped me

Else
mresult=MessageRequester("Warning","Funny, no server found... is it running????",#PB_MessageRequester_Ok)
End
EndIf
;
; good con
;
cid=OpenNetworkConnection("192.168.0.1",9999)
If cid
If opcon
PrintN("Ok, found server.")
EndIf
connsendstring("theshadeshadowsn")
;This time i drop myself

CloseNetworkConnection(cid)
Else
mresult=MessageRequester("Warning","Funny, no server found... is it running????",#PB_MessageRequester_Ok)
End
EndIf
mresult=MessageRequester("Warning","Just waiting for server to either auth or drop....",#PB_MessageRequester_Ok)