PDA

Click to See Complete Forum and Search --> : How to send data using a stream


mojo69
Oct 28th, 2007, 10:17 AM
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.

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

Hack
Nov 1st, 2007, 06:41 AM
I see the checkmark.

Is this resolved?

mojo69
Nov 1st, 2007, 06:53 PM
Not yet. Not sure what you mean by check mark?