Click here to Skip to main content
15,890,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak14-Aug-09 8:10
mveDave Kreskowiak14-Aug-09 8:10 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dambod14-Aug-09 8:25
Dambod14-Aug-09 8:25 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak14-Aug-09 8:35
mveDave Kreskowiak14-Aug-09 8:35 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Paramu197314-Aug-09 19:46
Paramu197314-Aug-09 19:46 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak15-Aug-09 2:21
mveDave Kreskowiak15-Aug-09 2:21 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Paramu197315-Aug-09 6:08
Paramu197315-Aug-09 6:08 
GeneralSolved Pin
Dambod16-Aug-09 3:58
Dambod16-Aug-09 3:58 
QuestionVB.net 2008, TCPClient Streams Pin
DaveAuld14-Aug-09 7:21
professionalDaveAuld14-Aug-09 7:21 
Hi all,

This is my first real attempt at playing with networking comms, so be gentle!

I have been struggling to get this to work. I have looked at the examples on here, and countless others returned by Google, i have also been reading the msdn documents, and what i have looks logical and partly works.

What i am trying to do is;
1) Open the TCP connection
2) Read the Byte stream and pass off blocks of bytes for processing elsewhere.

I can succesfully open the connection and async callback are entering the stream reader so I *think* the problem lies in there. I don't know how many different things i have added/removed but still not reading the bytes.

Any clues as to what i am doing wrong?

Private Client As New TcpClient
Private _readBufferSize As Integer = 128
Private ClientStreamBuffer(_readBufferSize) As Byte

Public Event DataToProcess(ByVal Buffer() As Byte)
Public Event ConnectionStateChange(ByVal Connected As Boolean)


Async connect call
Public Sub Connect(ByVal Host As String, ByVal Port As String)

    Try
        Client.NoDelay = True

        Client.ReceiveTimeout = 30

        Client.BeginConnect(Host, Port, AddressOf ConnectionResponse, Nothing)

    Catch ex As Exception
        Debug.WriteLine("Connect Failure: " + ex.Message)
    End Try

End Sub

Connection delegate
Private Sub ConnectionResponse(ByVal Ar As IAsyncResult)

    Try
          'accept the connection
          Client.EndConnect(Ar)

          RaiseEvent ConnectionStateChange(Client.Connected)

          'start an async read of the clients datastream
          Client.GetStream.BeginRead(ClientStreamBuffer, 0, _readBufferSize, AddressOf ClientStreamReader, Nothing)
    Catch ex As Exception
        Debug.WriteLine("TCPIP Connection Failed: " + ex.Message)
    End Try
End Sub


Stream Reader;
Private Sub ClientStreamReader(ByVal Ar As IAsyncResult)

    Try
        Dim bytesRead As Integer = Client.GetStream.EndRead(Ar)

        Dim bytesToProcess(bytesRead - 1) As Byte

        'Copy data off the buffer into the process array
        Array.Copy(ClientStreamBuffer, 0, bytesToProcess, 0, bytesRead)

        'do something like raise an event with BytesToProcess
        RaiseEvent DataToProcess(bytesToProcess)

        'Start the read again
        Client.GetStream.BeginRead(ClientStreamBuffer, 0, _readBufferSize, AddressOf ClientStreamReader, Nothing)

    Catch ex As Exception
        Debug.WriteLine("StreamReader Problem: " + ex.Message)
    End Try
End Sub

The next method is what i would use to handle the individual blocks of bytes from the stream;
Handling it locally at the moment, but will probably reside in a different place later. just using it to see what byte blocks are being raised.
Private Sub TCPIPComms_DataToProcess(ByVal Buffer() As Byte) Handles Me.DataToProcess
    Debug.WriteLine("Data Buffer Available bytes: " + Buffer.Length.ToString)

    'Do something with the bytes...............
End Sub



AnswerRe: VB.net 2008, TCPClient Streams Pin
Dave Kreskowiak14-Aug-09 8:07
mveDave Kreskowiak14-Aug-09 8:07 
GeneralRe: VB.net 2008, TCPClient Streams Pin
DaveAuld14-Aug-09 8:30
professionalDaveAuld14-Aug-09 8:30 
QuestionHow can I force a user to enter a string with characters only with no integer from a text box? Pin
waner michaud14-Aug-09 6:45
waner michaud14-Aug-09 6:45 
AnswerRe: How can I force a user to enter a string with characters only with no integer from a text box? Pin
Dave Kreskowiak14-Aug-09 7:42
mveDave Kreskowiak14-Aug-09 7:42 
AnswerRe: How can I force a user to enter a string with characters only with no integer from a text box? Pin
waner michaud14-Aug-09 11:41
waner michaud14-Aug-09 11:41 
GeneralRe: How can I force a user to enter a string with characters only with no integer from a text box? Pin
Luc Pattyn14-Aug-09 12:38
sitebuilderLuc Pattyn14-Aug-09 12:38 
Questionpassing values from a windows form to a crystal report Pin
myinstincts14-Aug-09 0:12
myinstincts14-Aug-09 0:12 
AnswerRe: passing values from a windows form to a crystal report Pin
Johan Hakkesteegt14-Aug-09 0:41
Johan Hakkesteegt14-Aug-09 0:41 
GeneralRe: passing values from a windows form to a crystal report Pin
myinstincts14-Aug-09 1:57
myinstincts14-Aug-09 1:57 
GeneralRe: passing values from a windows form to a crystal report Pin
Johan Hakkesteegt14-Aug-09 2:10
Johan Hakkesteegt14-Aug-09 2:10 
GeneralRe: passing values from a windows form to a crystal report Pin
myinstincts14-Aug-09 2:17
myinstincts14-Aug-09 2:17 
GeneralRe: passing values from a windows form to a crystal report Pin
Johan Hakkesteegt14-Aug-09 2:43
Johan Hakkesteegt14-Aug-09 2:43 
GeneralRe: passing values from a windows form to a crystal report Pin
myinstincts14-Aug-09 2:49
myinstincts14-Aug-09 2:49 
AnswerRe: passing values from a windows form to a crystal report Pin
Anubhava Dimri17-Aug-09 0:07
Anubhava Dimri17-Aug-09 0:07 
QuestionBring to Front and Send to back Pin
Anubhava Dimri13-Aug-09 23:55
Anubhava Dimri13-Aug-09 23:55 
AnswerRe: Bring to Front and Send to back Pin
0x3c014-Aug-09 0:17
0x3c014-Aug-09 0:17 
GeneralRe: Bring to Front and Send to back Pin
Coding C#14-Aug-09 2:50
Coding C#14-Aug-09 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.