Results 1 to 3 of 3

Thread: UDP Application Crash

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    2

    UDP Application Crash

    Hi guys

    I am a hobby programmer, but i have a problem right now that has had me stumped for 3 days now.

    I am sending a string to a server and the server is returning an answer.
    Everything works nicely, until I close the application.
    Then everything crashes.
    I have tried everything, but i cant find the problem.

    PLEASE HELP

    very basic a button to start a timer, wich inturn clocks the send routins every 5 sec.

    Receive routine just splits the data and puts it into text fields.
    Code:
    Private Sub cmdCon_Click()
        sock.RemoteHost = txtIP.Text
        sock.RemotePort = txtPort.Text
        sock.Bind
        txtIP.Enabled = False
        txtPort.Enabled = False
        ReadTimer.Enabled = True
        cmdCon.Enabled = False
        cmdDiscon.Enabled = True
    End Sub
    --------------------------------------------------------------------------
    Private Sub cmdDiscon_Click()
        sock.Close
        txtIP.Enabled = True
        txtPort.Enabled = True
        cmdCon.Enabled = True
        cmdDiscon.Enabled = False
        ReadTimer.Enabled = False
    End Sub
    --------------------------------------------------------------------------
    Private Sub Form_Unload(Cancel As Integer)
        If sock.State <> sckClosed Then
            sock.Close
        End If
    End Sub
    --------------------------------------------------------------------------
    Private Sub ReadTimer_Timer() '5sec timer for sending data
    Dim hData As String
    
        txtIP.Text = Trim$(txtIP.Text)
        txtPort.Text = Trim$(txtPort.Text)
    
        If Len(txtIP.Text) > 0 And Len(txtPort.Text) > 0 And IsNumeric(txtPort.Text) Then
    
            sock.SendData "\xFE\xFD\"           'data send
    
        End If
    End Sub
    --------------------------------------------------------------------------
    Private Sub sock_DataArrival(ByVal bytesTotal As Long) 'receive data
    Dim strData As String
    Dim Nato As String
    Dim Miles As String
    Dim Cheats As String
    Dim Official As String
    Dim Pb As String
    Dim Tourney As String
    Dim v As Variant
    
        sock.GetData strData, vbString, bytesTotal
    
        v = Split(strData, "\")
    
        ServerName.Text = v(2)
        MapName.Text = v(10)
        Players.Text = v(14)
        MaxPlayers.Text = v(18)
        MissionTime.Text = v(44)
        AverageHonor.Text = v(64)
        MaxHonor.Text = v(38)
        MinHonor.Text = v(36)
        AveragePing.Text = v(74)
        CurRound.Text = v(42)
        AdminName.Text = v(56)
        AdminEmail.Text = v(58)
     
    End Sub
    Last edited by Hack; May 16th, 2008 at 06:39 AM. Reason: Added Code Tags

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: UDP Application Crash

    Welcome to the forums.

    I have edited your first post and added [code]your code goes here[/code] tags. As I'm sure you can see, this makes reading posted code a lot easier.

    Please define "crashes". What does that mean here? What error do you get, and what code is causing it?

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    2

    Re: UDP Application Crash

    Ah ok sorry about that, total noob here.

    Well to your first question, i dont get an error as such.
    When I close the app the form disapears, but in the task manager it says not resonding, and i have to kill it there.

    I did notice that when i comment out the send command, it does not happen.

    Does that make any sence at all ?

    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width