Re: Winsock SendData Problem
first u need winsock1.connect , and than first send the data if winsock1.state = 7
Re: Winsock SendData Problem
Hi,
Thanks for your reply!
Could you please tell me where in my code I need to put Winsock1.connect ?
Thanks in advance!
Best Regards,
~url
Re: Winsock SendData Problem
VB Code:
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "You didnt fill out all fields", vbCritical, "Error!"
Winsock1.RemoteHost = Text1.Text
Winsock1.RemotePort = 1980
[B]if Winsock1.State = 7 then[/B] Winsock1.SendData "ban," + Text2.Text + "," + Text2.Text + "," + Text4.Text
MsgBox Text3.Text + " has been banned!"
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "You didnt fill out all fields", vbCritical, "Error!"
Winsock1.RemoteHost = Text1.Text
Winsock1.RemotePort = 1980
[B]if Winsock1.State = 7 then[/B] Winsock1.SendData "unban," + Text3.Text + "," + Text2.Text + "," + Text4.Text
MsgBox Text2.Text + " has been unbanned!"
End Sub
ss
Re: Winsock SendData Problem
hm.. not very well... try this , sry with the timer1 code xD
First create a third button with caption connect then a timer with interval 1
VB Code:
Private Sub Command3_Click()
if winsock1.state = 0 then
winsock1.RemoteHost
Winsock1.RemoteHost = Text1.Text
Winsock1.RemotePort = 1980
endif
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "You didnt fill out all fields", vbCritical, "Error!"
if winsock1.state = 7 then
Winsock1.SendData "ban," + Text2.Text + "," + Text2.Text + "," + Text4.Text
MsgBox Text3.Text + " has been banned!"
else
MsgBox "Press the connect button first"
endif
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then MsgBox "You didnt fill out all fields", vbCritical, "Error!"
if winsock1.state = 7 then
Winsock1.SendData "unban," + Text3.Text + "," + Text2.Text + "," + Text4.Text
MsgBox Text2.Text + " has been unbanned!"
else
MsgBox "Press the connect button first"
endif
End Sub
Private Sub Timer1_dont know atm sry xD()
if winsock1.state = 8 then
MsgBox "you have been disconnected"
winsock1.close
endif
if winsock1.state = 9 then
MsgBox "Connection could not been established , check the ip and ur network connection!"
winsock1.close
endif
end sub
Re: Winsock SendData Problem
there is a a lot more to winsock (as I am learning) than just sending data. I just indicated where the connection state test would be placed (as was aksed). But there is much more about his gameserver management that is not indicated. Is this a multiclient server, what is the criteria for banning? if mulitclient, are you sending ban commnad to proper client?
take a look at these to get a handle on winsock server mutilclient programming
http://www.winsockvb.com/article.php?article_id=18
http://www.winsockvb.com/article.php?article_id=19