Click here to Skip to main content
15,891,248 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How can objects on different threads communicate with one another? Pin
Rizwan Bashir17-May-06 22:57
Rizwan Bashir17-May-06 22:57 
AnswerRe: How can objects on different threads communicate with one another? Pin
jonathan1517-May-06 23:02
jonathan1517-May-06 23:02 
QuestionDISTINCT in crystal report Pin
microuser_200017-May-06 21:40
microuser_200017-May-06 21:40 
AnswerRe: DISTINCT in crystal report Pin
Rizwan Bashir17-May-06 22:58
Rizwan Bashir17-May-06 22:58 
GeneralRe: DISTINCT in crystal report Pin
microuser_200017-May-06 23:34
microuser_200017-May-06 23:34 
GeneralRe: DISTINCT in crystal report Pin
Rizwan Bashir19-May-06 21:56
Rizwan Bashir19-May-06 21:56 
GeneralRe: DISTINCT in crystal report Pin
microuser_200019-May-06 23:37
microuser_200019-May-06 23:37 
QuestionSending large binary data through Asynchronous Sockets in VB.NET??Plz Help Pin
shelal17-May-06 21:21
shelal17-May-06 21:21 
Hi all,,
I am trying to make a vb.net socket that allow user to upload image files from clients machines to server machine. i searched the net and i found the following code samples.

Code for Server:-
Const portNo As Integer = 500
Dim localAdd As System.Net.IPAddress = _
    IPAddress.Parse("127.0.0.1")
Dim listener As New TcpListener(localAdd, portNo)
listener.Start()
Console.WriteLine("Listening...")

Dim tcpClient As TcpClient = listener.AcceptTcpClient()
Dim NWStream As NetworkStream = tcpClient.GetStream
Dim bytesToRead(tcpClient.ReceiveBufferSize) As Byte

'---read incoming stream
Dim numBytesRead As Integer = NWStream.Read(bytesToRead, _
                        0, CInt(tcpClient.ReceiveBufferSize))

'---write the bytes to file
Const FILE_NAME = "c:\image.gif"
Dim fs As System.IO.FileStream
fs = New FileStream(FILE_NAME, FileMode.CreateNew, _
                    FileAccess.Write)
fs.Write(bytesToRead, 0, numBytesRead)
fs.Close()

tcpClient.Close()
listener.Stop()
Console.ReadLine()


Code for Client:-
Const portNo = 500
Const FILE_NAME = "c:\ondotnet_logo.gif"
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("127.0.0.1", portNo)

Dim NWStream As NetworkStream = tcpclient.GetStream
Dim bytesToSend(tcpClient.ReceiveBufferSize) As Byte

Dim fs As FileStream
fs = New FileStream(FILE_NAME, FileMode.Open, _
                    FileAccess.Read)
Dim numBytesRead As Integer = fs.Read(bytesToSend, _
                    0, bytesToSend.Length)
fs.Close()

'---send the text
Console.WriteLine("Sending ...")
NWStream.Write(bytesToSend, 0, numBytesRead)

Console.ReadLine()
tcpclient.Close()



I tried the code and it worked succesfully..but i noticed that the new file image.gif will be corrupted if the original one has size larger than 8192 bytes!!

1- i don't know how to make it works for larger files!!!
2- i need it to be work if multiple users upload file at the same time!!!

i am new in sockets programming Sigh | :sigh: , so any comment will be very helpful Big Grin | :-D

thanks
shelal

shelal

-- modified at 3:25 Thursday 18th May, 2006
QuestionReading from Text file Pin
Amarni17-May-06 20:53
Amarni17-May-06 20:53 
AnswerRe: Reading from Text file Pin
Colin Angus Mackay17-May-06 21:11
Colin Angus Mackay17-May-06 21:11 
GeneralRe: Reading from Text file Pin
Amarni17-May-06 21:59
Amarni17-May-06 21:59 
GeneralRe: Reading from Text file Pin
Steve Pullan17-May-06 22:15
Steve Pullan17-May-06 22:15 
GeneralRe: hhhhhhhh Pin
Amarni17-May-06 22:34
Amarni17-May-06 22:34 
GeneralRe: hhhhhhhh Pin
J4amieC17-May-06 23:00
J4amieC17-May-06 23:00 
GeneralRe: hhhhhhhh Pin
Steve Pullan18-May-06 0:37
Steve Pullan18-May-06 0:37 
GeneralRe: hhhhhhhh Pin
_AK_18-May-06 2:06
_AK_18-May-06 2:06 
QuestionEarly and Late Binding Pin
Scorpio17-May-06 19:36
Scorpio17-May-06 19:36 
AnswerRe: Early and Late Binding Pin
Steve Pullan17-May-06 21:17
Steve Pullan17-May-06 21:17 
GeneralHints: Early and Late Binding Pin
MohammadAmiry18-May-06 5:16
MohammadAmiry18-May-06 5:16 
QuestionDotNetNuke Skin Pin
Kakuji17-May-06 18:57
Kakuji17-May-06 18:57 
QuestionHow to customize WSE policy Pin
hung_ngole17-May-06 18:32
hung_ngole17-May-06 18:32 
QuestionControl MenuItem on MDI application Pin
minhnguyen0817-May-06 16:54
minhnguyen0817-May-06 16:54 
QuestionLOGONUSER Pin
mlauahi17-May-06 13:59
mlauahi17-May-06 13:59 
AnswerRe: LOGONUSER Pin
progload17-May-06 14:45
progload17-May-06 14:45 
GeneralRe: LOGONUSER Pin
mlauahi18-May-06 5:09
mlauahi18-May-06 5:09 

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.