|
-
Sep 22nd, 2007, 02:21 AM
#1
Thread Starter
New Member
Help With Winsock ( Send Packet )
Spanish / English
Buenas noches, necesito crear un programa en Visual Basic que haga lo siguiente:
Al tocar la tecla "X" se envie el paquete de informacion ( 05 0E por ejemplo ) a tal direcion de ip mediante tal socket ...
Tengo el ip, tengo el socket, tengo el paquete, me faltaria solo saber como enviarlo, alguna solucion? ...
****************************
****************************
Good night, I need to create a program in Visual Basic that does the following thing:
When touching the key "X" send the packet of information (05 0E for example) to so address of IP by means of so socket ...
I have the IP, I have socket, I have the package, but not like sending it, some solution? ...
Notes:
Ip: 127.0.0.1 ( for example )
Socket: 1000
Port: 7500
Packet: 05 0E
Edit:
Code:
Private Sub Command1_Click()
Dim myArr(1) As Byte
myArr(0) = 5
myArr(1) = 0
Winsock1.RemoteHost = "xxx.xxx.xxx.xxx"
Winsock1.RemotePort = xxxx
Winsock1.LocalPort = "xxxx"
Winsock1.SendData myArr
End Sub
Error:

Last edited by Jorgitoh; Sep 22nd, 2007 at 04:24 AM.
-
Sep 22nd, 2007, 04:13 AM
#2
Thread Starter
New Member
Re: Help With Winsock ( Send Packet )
Edited ...
Last edited by Jorgitoh; Sep 22nd, 2007 at 05:09 AM.
Reason: Duplicate Post
-
Sep 22nd, 2007, 10:27 AM
#3
Re: Help With Winsock ( Send Packet )
first, before using any winsock code, put:
winsock.close
then make sure you put the acutal index of the array you want to send.
winsock.senddata myarr(x)
'substitute x with the array index
You are also going to need to have an application listening on the port you are sending the data to. If you already have this then don't worry. If you want to know more about winsock, go to the NETWORKING section of the forums. There's a lot of frequently asked questions there.
Last edited by drivenbywhat; Sep 22nd, 2007 at 10:30 AM.
[vb5 & starting to move to vb2008] I appreciate the help I get from everyone. Thank you. 
-
Sep 22nd, 2007, 12:41 PM
#4
Thread Starter
New Member
Re: Help With Winsock ( Send Packet )
I want to send all those together bytes in chain form, for that reason I do not put the (x) next to myarr...
I already have a game running in that IP and that port (remote host & port), therefore the connection already this established, anyway to me continues appearing the error...
-
Sep 22nd, 2007, 12:55 PM
#5
Re: Help With Winsock ( Send Packet )
even if you want to send all the values use a loop to loop thru your array and then send it...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Sep 22nd, 2007, 03:24 PM
#6
Re: Help With Winsock ( Send Packet )
Did you put the "winsock.close" like I told you? Your error is saying it is in the wrong state for what you are trying to do. This means that either you are "listening" somewhere and shouldn't be because you are trying to connect. It could also mean that winsock isn't even connecting. Try the following code:
vb Code:
Dim myArr(1) As Byte
myArr(0) = 5
myArr(1) = 0
winsock1.close
Winsock1.RemoteHost = "xxx.xxx.xxx.xxx"
Winsock1.RemotePort = xxxx
'you need this so you can connect before trying to send anything!
winsock1.connect
'no need for local port, it already knows this itself
'Winsock1.LocalPort = "xxxx"
'make sure to declare x
for x = 0 to 1
Winsock1.SendData myArr(x)
next x
That should work for you.
[vb5 & starting to move to vb2008] I appreciate the help I get from everyone. Thank you. 
-
Sep 22nd, 2007, 03:44 PM
#7
Thread Starter
New Member
Re: Help With Winsock ( Send Packet )
-
Sep 22nd, 2007, 07:01 PM
#8
Re: Help With Winsock ( Send Packet )
"The game to which I want to send this information to him finds walking", what does that mean? "him finds walking"???????????
Anyways, that error that you are getting is due to the state of the connection. What game is it that has the connection established already? Is it one you made? If it's not, do you know if that game uses winsock? Do you know what commands it expects? Also, is that game's port listening to a connection? Does it have multiple winsock controls to accept more than one connection? If it's already established and only has 1 winsock control listening, it can't establish yet another connection to it.
[vb5 & starting to move to vb2008] I appreciate the help I get from everyone. Thank you. 
-
Sep 22nd, 2007, 07:51 PM
#9
Thread Starter
New Member
Re: Help With Winsock ( Send Packet )
...
Last edited by Jorgitoh; Oct 12th, 2007 at 09:24 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|