| Dart Home | PowerTCP Sockets for .NET | Custom Development | Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
| Author | Forum: PowerTCP Sockets for .NET (Secure and Standard) Topic: Please help!! |
| marus From: UA, MN USA Posts: 3 Member Since: 12/06/04 |
posted December 6, 2004 10:20 PM I am programming a tcp socket class in my VB.net project. But there is an error from the DLL and I have no idea on it. Please help, thanks. Source Code: ---------------------- Imports System.Text Imports System.Threading Imports Dart.PowerTCP.Sockets Public Class TCP2 Private tcpsocket As Dart.PowerTCP.Sockets.Tcp Private Buffer() As Byte Public Sub New() tcpsocket = New Dart.PowerTCP.Sockets.Tcp() End Sub Sub connect(ByVal StreamingIP As String, ByVal StreamingPort As Integer) Dim addr As System.Net.IPAddress Dim serverendpoint As System.Net.IPEndPoint Dim cb As System.Text.Encoding Dim receivebuffer(10000) As Byte Dim rc As Integer Dim N As Integer Dim Code As String Dim Retry As Integer ' Register N for this thread N = Teletext_N ' Increase array size by 1 ReDim Preserve EngineState(N) ' Enable Engine EngineState(N) = 1 ' Start connect to the server addr = System.Net.IPAddress.Parse(StreamingIP) serverendpoint = New System.Net.IPEndPoint(addr, StreamingPort) tcpsocket.BeginConnect(StreamingIP, StreamingPort) Thread.Sleep(5000) tcpsocket.Send(cb.ASCII.GetBytes(login_password & vbCrLf)) Thread.Sleep(1000) tcpsocket.Send(cb.ASCII.GetBytes(Code & vbCrLf)) Try MsgBox(tcpsocket.BeginReceive(receivebuffer)) Catch End Try End Sub Sub tcpsocket_EndReceive(ByVal sender As System.Object, ByVal e As Dart.PowerTCP.Sockets.SegmentEventArgs) ' Fires when Receive has completed Try ' Display received data Dim s As String s = e.Segment.ToString() ' Begin asynch Receive If tcpsocket.Connected Then tcpsocket.BeginReceive(Buffer) End If Catch ex As Exception End Try End Sub Sub tcpsocket_EndConnect(ByVal sender As System.Object, ByVal e As Dart.PowerTCP.Sockets.ExceptionEventArgs) 'Fires when connection has been established If e.Exception Is Nothing Then Try 'Begin asynch Receive ReDim Buffer(tcpsocket.ReceiveBufferSize) tcpsocket.BeginReceive(Buffer) Catch ex As Exception ShowError(ex.Message) End Try Else ShowError(e.Exception.Message) End If End Sub Private Sub ShowError(ByVal msg As String) MsgBox(msg, MsgBoxStyle.Exclamation, "TCP Client Error") End Sub Private Sub tcpsocket_ConnectedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Fires when Connection is established or closed 'Note: When Secure connection, fires after initial unsecure connection established If (tcpsocket.Connected) Then Else End If End Sub End Class |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted December 6, 2004 10:51 PM What error are you getting? Have you looked at any of the sample apps? |
| marus From: UA, MN USA Posts: 3 Member Since: 12/06/04 |
posted December 6, 2004 11:59 PM The error is: An unhandled exception of type 'System.InvalidOperationException' occurred in dart.powertcp.sockets.dll Additional information: BeginXXX() is called without providing an event handler for EndXXX. You must provide an event handler for all asynchronous methods. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted December 7, 2004 12:19 AM You need to hookup your events. Add "Handles " and then the name of the event to the end of the declaration. You may want to take a look at the Tcp Client sample as it implements all of the events. |
| marus From: UA, MN USA Posts: 3 Member Since: 12/06/04 |
posted December 7, 2004 12:52 AM OH GOD..this is my big mistake Thank you Tony. |
| Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|