Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications

Post new topic   Reply to topic
UDP (Packets send)
View previous topic :: View next topic  
Author Message
raj
Newbie


Joined: 27 Apr 2005
Posts: 1

PostPosted: Apr 27th, 2005 07:33 AM    Post subject: UDP (Packets send) Reply with quote

I am making an application in which I am sending parameters as Packetsize Numberofpackets..Packetsize mean number of bytes in one packet...The code is as follows..

Private Sub send_Click()
Dim count As Variant
On Error Resume Next
If Socket.State <> 1 Then
Socket.LocalPort = 0
End If
numberofpackets = 0
count = 0
Socket.RemoteHost = sendaddr.Text
Socket.RemotePort = sendport.Text
Do While Not numberofpackets = pcktnumber.Text
count = count + 1
If count = pcktsize.Text Then
numberofpackets = numberofpackets + 1
count = 0
Socket.SendData (numberofpackets)
timer1.interval = delay.text (The delay time will be according to user put in textbox, if he put 1000 than it will be equal to 1 second delay)
(Its delay between two packets, After senidng one data it should send other after this much delay)
End If
Loop
recep.Text = recep.Text & " Server " & " " & " Packet Size " & " " & " Packet Send " & " " & " Packet Time" & vbCrLf & Socket.LocalIP & " " & pcktsize.Text & " " & numberofpackets & vbCrLf & vbCrLf
'Text1.Text = ""
'Text2.Text = ""
End Sub

Private Sub Socket_DataArrival(ByVal bytesTotal As Long)
Dim packetsreceived As Variant
Dim Bytesreceived As Variant
Socket.GetData packetsreceived, vbInteger
recep.Text = ""
recep.Text = recep.Text & " IP Address " & " " & " Packet Received " & " " & " Bytes Received " & vbCrLf & Socket.LocalIP & " " & packetsreceived & " " & Bytesreceived & vbCrLf & vbCrLf
sendaddr.Text = Socket.RemoteHostIP
sendport.Text = Socket.RemotePort
Beep
End Sub

Private Sub Socket_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Erreur avec le socket! & vbcrlf # " & Number & vbCrLf & Description
Socket.Close
End Sub

Private Sub Timer1_Timer()

End Sub


Problem is that when I am sending number of packets it stays in loop and than send total number of bytes which is not correct anyone knows how to send data as bytes per byte....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic