KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Socket trouble : Stop receiving packets
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Thu Sep 02, 2004 1:39 pm    Post subject: Socket trouble : Stop receiving packets Reply with quote

Shawn,

I continue to work on my IM program, and it's fairly stable now. Which means I'm finally ready to ask about this problem that I've noticed for awhile.

After an indeterminate amount of time, a script utilizing sockets just stops receiving or sending them (I'm not sure which). I see this time to time on my IM script, and I even see it in your chat room script. I've also noticed that it happens much more frequently when the server and client are running on the same machine.

I modified your chatroom script to log everything the server and client sends/receives. This is what happened...

SERVER CLIENT(Bonji) CLIENT(Ben)

I have two clients connected to the server. Bonji is chatting fine with Ben and vice versa. After a short while, messages that Ben tries to send are no longer processed by the server. Ben still receives messages from Bonji, but Bonji does not get any more messages from Ben no matter what Ben tries to type.

I was able to duplicate this problem with logging enabled and here is what that showed. The logs show Ben's messages are sent, but the server never received it. So I'm not sure if the client send is getting broken or the server's receive, but you should be able to duplicate the situation without too much effort. If this problem doesn't happen fairly quick (within 30 messages) than close everything down and restart it. I found that if I couldn't get it to break early, then I could never get it to break. However, it breaks about a third of the time I run the scripts.

Make sense?

Ramble Ramble Ramble **SLAP**

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Sep 02, 2004 1:56 pm    Post subject: Reply with quote

have you utilized ondisconnect() ?

also, have you logged also the times?
valuable info is connection time and possible idle time of the user and idle time of the socket.
also, data packet amount and size is nice.

I've been having around halfn' hour game sessions with my game and I've not noticed anything like this.
the game-data goes fine and so does chattie...

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Thu Sep 02, 2004 2:05 pm    Post subject: Reply with quote

I used Shawn's script right out of the box and this happens. I only modified it to add the logging to give me some idea of where the breakdown occurred.

I'm surprised this would happen consistantly with me, but not at all with anyone else.

There is no idle time as I send messages repeatedly until it breaks (which usually only takes a few seconds when it does). I'm not sure of the packet size, but I send short messages when trying to break it.

I experience this on every script that uses sockets. I am running Windows XP Pro w/SP2 (happened when I was on SP1) on a Toshiba Satellite P25 laptop.

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Sep 02, 2004 5:01 pm    Post subject: Reply with quote

shawn's script?
which one?

as you don't talk about errors, I take you don't log errors at all.
basically, would like to know if ondisconnect triggers and if it does or does not, what the lasterror looks like.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Thu Sep 02, 2004 7:16 pm    Post subject: Reply with quote

The chat room script included in the socket pack.

There are no errors. The socket is still connected. It just doesn't send (or receive on the server side). OnDisconnect never fires. The broken client can still receive it just can't send or the broken server socket can send but not receive. I checked the $System.(s)error and it always says successful on the send. I can't verify the receive because the server receive never fires once broken.

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Sep 03, 2004 3:37 am    Post subject: Reply with quote

k, back to the timing...
if you leave the messages out.
wait for minute or so and start chatting, does it work at all?

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Sep 03, 2004 11:33 am    Post subject: Reply with quote

Once broken, I have to restart the script to get it to communicate normally again.

Is that what you are asking?

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Sep 03, 2004 12:29 pm    Post subject: Reply with quote

no.
start the script and wait a "lot" of time and does it work?
if yes, keep shooting until it breaks.

the meaning being, is the time a factor here or is the data size.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Sep 03, 2004 12:36 pm    Post subject: Reply with quote

It doesn't seem to be a time issue as my IM script will be working most of the day and then one of the clients (i'm only testing with two people right now) will experience this problem. It doesn't happen every day, but when it does it can happen early on or after awhile.

I know this isn't good info, but this has been a tricky problem.

Not sure if data size is a problem either as I'll send long messages frequently, and it can break on a long or short one with long or short messages preceeding.

Oh well Sad

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Sep 03, 2004 1:13 pm    Post subject: Reply with quote

and no error...
hmm...

just wonder what happens if the server receives 2 socket events at the same time...

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Sep 03, 2004 1:20 pm    Post subject: Reply with quote

Hmmm....I'll give that a try and see what happens.
_________________
-Ben
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Wed Sep 22, 2004 2:19 pm    Post subject: Reply with quote

I created a sample script for troubleshooting this problem. It is a server and has two clients built in. Either client can connect/disconnect at will and the server can also be started/stopped.

I have a special little button that makes both clients send (probably not completely parrallel, but still two immediate sends) a message to the server.

I can duplicate the problem whether I make both send or send with only one at a time. I have migrated to a new computer since I first started working on this problem, and it experiences the same behavior. I'm still surprised I'm the only one that has seen this.

Any thoughts?

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Sep 22, 2004 3:12 pm    Post subject: Reply with quote

shawn, once you decide to come down from the heavens or wherever you are at the moment, could you shoot us (or just bonji) a little nice debug mode build.

thanks.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Sep 24, 2004 8:11 pm    Post subject: Reply with quote

Here's the code to the script I made. It's not tweaked perfectly, but I only was trying to get a product to test on. I guess you guys can see if you can break it.

Code:

Break On

$cln1Socket = ""
$cln2Socket = ""

$System            = CreateObject("Kixtart.System")
$Form            = $System.Form
$Form.Size         = 600,460
$Form.Text         = "Test Server"

$grpServer         = $Form.GroupBox("Server")
$grpServer.Size         = 580,180
$grpServer.Location      = 5,10
$txtSrvChat         = $grpServer.TextBox
$txtSrvChat.Size      = 560,100
$txtSrvChat.Location      = 10,20
$txtSrvChat.MultiLine      = 1
$txtSrvChat.AcceptsReturn   = 1
$txtSrvChat.ScrollBars      = 2
$cmdSrvSend         = $grpServer.Button("Send")
$cmdSrvSend.Size      = 60,21
$cmdSrvSend.Location      = 10,130
$cmdSrvSend.OnClick      = "cmdSrvSend_Click()"
$cmdSrvLstn         = $grpServer.Button("Listen")
$cmdSrvLstn.Size      = 60,21
$cmdSrvLstn.Location      = 100,130
$cmdSrvLstn.OnClick      = "cmdSrvLstn_Click()"
$cmdSrvStop         = $grpServer.Button("Stop")
$cmdSrvStop.Size      = 60,21
$cmdSrvStop.Location      = 200,130
$cmdSrvStop.OnClick      = "cmdSrvStop_Click()"
$lblSrvSts1         = $grpServer.Label("Server Status:")
$lblSrvSts1.Size      = 70,15
$lblSrvSts1.Location      = 10,160
$lblSrvSts2         = $grpServer.Label("Idle")
$lblSrvSts2.Size      = 480,15
$lblSrvSts2.Location      = 90,160

$grpClient1         = $Form.GroupBox("Client 1")
$grpClient1.Size      = 280,180
$grpClient1.Location      = 5,200
$txtCln1Chat         = $grpClient1.TextBox
$txtCln1Chat.Size      = 260,100
$txtCln1Chat.Location      = 10,20
$txtCln1Chat.MultiLine      = 1
$txtCln1Chat.AcceptsReturn   = 1
$txtCln1Chat.ScrollBars      = 2
$cmdCln1Send         = $grpClient1.Button("Send")
$cmdCln1Send.Size      = 60,21
$cmdCln1Send.Location      = 10,130
$cmdCln1Send.OnClick      = "cmdCln1Send_Click()"
$cmdCln1Cnct         = $grpClient1.Button("Connect")
$cmdCln1Cnct.Size      = 60,21
$cmdCln1Cnct.Location      = 80,130
$cmdCln1Cnct.OnClick      = "cmdCln1Cnct_Click()"
$cmdCln1Disc         = $grpClient1.Button("Disc")
$cmdCln1Disc.Size      = 60,21
$cmdCln1Disc.Location      = 150,130
$cmdCln1Disc.OnClick      = "cmdCln1Disc_Click()"
$lblCln1Sts1         = $grpClient1.Label("Client Status:")
$lblCln1Sts1.Size      = 70,15
$lblCln1Sts1.Location      = 10,160
$lblCln1Sts2         = $grpClient1.Label("Idle")
$lblCln1Sts2.Size      = 180,15
$lblCln1Sts2.Location      = 90,160

$grpClient2         = $Form.GroupBox("Client 2")
$grpClient2.Size      = 280,180
$grpClient2.Location      = 305,200
$txtCln2Chat         = $grpClient2.TextBox
$txtCln2Chat.Size      = 260,100
$txtCln2Chat.Location      = 10,20
$txtCln2Chat.MultiLine      = 1
$txtCln2Chat.AcceptsReturn   = 1
$txtCln2Chat.ScrollBars      = 2
$cmdCln2Send         = $grpClient2.Button("Send")
$cmdCln2Send.Size      = 60,21
$cmdCln2Send.Location      = 10,130
$cmdCln2Send.OnClick      = "cmdCln2Send_Click()"
$cmdCln2Cnct         = $grpClient2.Button("Connect")
$cmdCln2Cnct.Size      = 60,21
$cmdCln2Cnct.Location      = 80,130
$cmdCln2Cnct.OnClick      = "cmdCln2Cnct_Click()"
$cmdCln2Disc         = $grpClient2.Button("Disc")
$cmdCln2Disc.Size      = 60,21
$cmdCln2Disc.Location      = 150,130
$cmdCln2Disc.OnClick      = "$$ = $$cln2Socket.Disconnect"
$lblCln2Sts1         = $grpClient2.Label("Client Status:")
$lblCln2Sts1.Size      = 70,15
$lblCln2Sts1.Location      = 10,160
$lblCln2Sts2         = $grpClient2.Label("Idle")
$lblCln2Sts2.Size      = 180,15
$lblCln2Sts2.Location      = 90,160

$cmdClose         = $Form.Button("Close")
$cmdClose.Size         = 60,21
$cmdClose.Location      = 270,400
$cmdClose.OnClick      = "$$Form = 'Nothing'"
$cmdClose.Cancel      = 1

$cmdDblSend         = $Form.Button("2 Send")
$cmdDblSend.Size      = 60,21
$cmdDblSend.Location      = 10,400
$cmdDblSend.OnClick      = "cmdDblSend_Click()"

$Form.Show
While $Form.Visible
   $ = Execute($Form.DoEvents)
Loop

;************************************************
;*      Server Functions      *
;************************************************
Function cmdSrvLstn_Click()
   $Sockets      = $System.Collection()
   $Listener      = $System.Socket()
   $Listener.Blocking   = 0
   $Listener.LocalAddress   = "0.0.0.0"
   $Listener.LocalPort   = "10"
   $Listener.OnAccept   = "evtAccept()"
   $ = $Listener.Bind()
   $ = $Listener.Listen
   $lblSrvSts2.Text   = "Listening..."
EndFunction

Function evtAccept()
   Dim $Socket
   $Socket = $Listener.Accept()
   If $Socket
      $Socket.Blocking = 0
      $Socket.OnReceive = "evtSrv_OnReceive($$System.EventObject)"
      $Socket.OnDisconnect = "evtSrv_Disconnect($$System.EventObject)"
      $Sockets.Add($Socket)
      $lblSrvSts2.Text = $Socket.LocalAddress + " is connected"
   EndIf
EndFunction

Function evtSrv_OnReceive($Socket)
   Dim $Data, $Data_Array
   $Data = $Socket.Receive()
   $Data_Array = Split($Data,"{}{}")
   $txtSrvChat.AppendText("Msg From: " + $Data_Array[0] + " : " + $Data_Array[1] + @CRLF)
EndFunction

Function evtSrv_Disconnect($Socket)
   $txtSrvChat.AppendText("A client disconnected" + @CRLF)
   $ = $Sockets.Remove(0)
EndFunction

Function cmdSrvStop_Click()
   $Listener = "Nothing"
   If $Sockets.Item(0)
      $Sockets.Item(0).Disconnect
   EndIf
   If $cln2Socket
      $Sockets.Item(1).Disconnect
   EndIf
   $lblSrvSts2.Text = "Idle"
EndFunction

Function cmdSrvSend_Click()
   If $cln1Socket
      $ = $Sockets.Item(0).Send("Server")
   EndIf
   If $cln2Socket
      $ = $Sockets.Item(1).Send("Server")
   EndIf
EndFunction


;************************************************
;*      Client 1 Functions      *
;************************************************
Function cmdCln1Cnct_Click()
   $cln1Socket = $System.Socket()
   If $cln1Socket
      $cln1Socket.Blocking = 0
      $cln1Socket.Connect("DulaneyB",10)
      $cln1Socket.OnConnect = "evtCln1_OnConnect($$System.EventObject)"
      $cln1Socket.OnDisconnect = "evtCln1_Disconnect($$System.EventObject)"
      $cln1Socket.OnReceive = "evtCln1_OnReceive($$System.EventObject)"
   EndIf
EndFunction

Function evtCln1_OnConnect($cln1Socket)
   If $System.Error
      $ = $Form.MessageBox($System.SError,$Ssystem.Error)
      $lblCln1Sts2.Text = "Idle"
      $ = $txtCln1Chat.Clear()
   Else
      $lblCln1Sts2.Text = "Connected to " + $cln1Socket.RemoteAddress
      $ = $txtCln1Chat.Clear()
   EndIf
EndFunction

Function evtCln1_OnReceive($cln1Socket)
   Dim $Data
   $Data = $cln1Socket.Receive()
   $ = $txtCln1Chat.AppendText($Data + @CRLF)
EndFunction

Function evtCln1_Disconnect($cln1Socket)
   $lblCln1Sts2.Text = "Idle"
   $ = $txtCln1Chat.Clear()
EndFunction

Function cmdCln1Send_Click()
   If $cln1Socket
      $ = $cln1Socket.Send("Client1{}{}" + $txtCln1Chat.Text)
      $ = $txtCln1Chat.Clear()
   EndIf
EndFunction

Function cmdCln1Disc_Click()
   $cln1Socket.Disconnect
   $ = $txtCln1Chat.Clear()
   $lblCln1Sts2.Text = "Idle"
EndFunction


;************************************************
;*      Client 2 Functions      *
;************************************************
Function cmdCln2Cnct_Click()
   $cln2Socket = $System.Socket()
   If $cln2Socket
      $cln2Socket.Blocking = 0
      $cln2Socket.Connect("DulaneyB",10)
      $cln2Socket.OnConnect = "evtCln2_OnConnect($$System.EventObject)"
      $cln2Socket.OnDisconnect = "evtCln2_Disconnect($$System.EventObject)"
      $cln2Socket.OnReceive = "evtCln2_OnReceive($$System.EventObject)"
   EndIf
EndFunction

Function evtCln2_OnConnect($cln2Socket)
   If $System.Error
      $ = $Form.MessageBox($System.SError,$Ssystem.Error)
      $lblCln2Sts2.Text = "Idle"
      $ = $txtCln2Chat.Clear()
   Else
      $lblCln2Sts2.Text = "Connected to " + $cln2Socket.RemoteAddress
      $ = $txtCln2Chat.Clear()
   EndIf
EndFunction

Function evtCln2_OnReceive($cln2Socket)
   Dim $Data
   $Data = $cln2Socket.Receive()
   $ = $txtCln2Chat.AppendText($Data + @CRLF)
EndFunction

Function evtCln2_Disconnect($cln2Socket)
   $lblCln2Sts2.Text = "Idle"
   $ = $txtCln2Chat.Clear()
EndFunction

Function cmdCln2Send_Click()
   If $cln2Socket
      $ = $cln2Socket.Send("Client2{}{}" + $txtCln2Chat.Text)
      $ = $txtCln2Chat.Clear()
   EndIf
EndFunction

Function cmdCln2Disc_Click()
   $cln2Socket.Disconnect
   $ = $txtCln2Chat.Clear()
   $lblCln2Sts2.Text = "Idle"
EndFunction

;************************************************
;*      Double Client Functions      *
;************************************************
Function cmdDblSend_Click()
   $CNT1 = $CNT1 + 1
   $CNT2 = $CNT2 + 1
   $ = $cln1Socket.Send("Client1{}{}Client1 : " + $CNT1)
   $ = $cln2Socket.Send("Client2{}{}Client2 : " + $CNT2)
EndFunction

_________________
-Ben
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Mon Sep 27, 2004 12:32 pm    Post subject: Reply with quote

A debug build sounds like it could be helpful.
_________________
-Ben
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group