How to send data using a stream
I want to send data from the server to the client using sockets. How can I do that? Once I get the data into a dataset I would like to return the dataset to the client program using a NetworkStream. Here is the code I have so far.
Code:
Public Sub listenerThread()
Dim tcpListener As New TcpListener(8080)
Dim handlerSocket As Socket
Dim thdstHandler As ThreadStart
Dim thdHandler As Thread
tcpListener.Start()
Do
handlerSocket = tcpListener.AcceptSocket
If handlerSocket.Connected Then
SyncLock (Me)
alSockets.Add(handlerSocket)
End SyncLock
thdstHandler = New ThreadStart(AddressOf handlerThread)
thdHandler = New Thread(thdstHandler)
thdHandler.Start()
End If
Loop
End Sub
Public Sub handlerThread()
Dim handlerSocket As Socket
handlerSocket = alSockets(alSockets.Count - 1)
Dim networkStream As NetworkStream = New NetworkStream(handlerSocket)
Dim blockSize As Int16 = 1024
Dim thisRead As Int16
Dim dataByte(blockSize) As Byte
Dim da As New DataAccess
SyncLock Me
Dim filestream As Stream
filestream = da.GetData("SELECT * FROM CKMF01")
''is this where the data is sent back???
''filestream = File.OpenWrite("C:\upload.txt")
While True
End While
End SyncLock
End Sub
Re: How to send data using a stream
I see the checkmark.
Is this resolved?
Re: How to send data using a stream
Not yet. Not sure what you mean by check mark?