CodyBarrett Posted July 21, 2009 Share Posted July 21, 2009 well for the last 3 months on and off i have been looking for a UDP example script that would be usefull to learn from.. i know how to make a TCP multiclient... though that needs a server.. what i would like is (for my current Chess PVP game project) is: *any UDP examples on how to do it without a server (person starts up game... waits and another person connects and they play..) *possibly some directions in where to learn from *is it even possible for a UDP serverliess PvP game.. i HAVE seen a few UDP examples around here... but i have no idea how they function.. so please any help? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Xand3r Posted July 22, 2009 Share Posted July 22, 2009 #include<GuiConstantsEx.au3> #include<GUIEdit.au3> #include<EditConstants.au3> #include<ButtonConstants.au3> Opt("GUIOnEventMode" , 1) UDPStartup() $s=UDPBind(@IPAddress1,8080) $d=UDPOpen("255.255.255.255" , 8080,1) $GUI=GUICreate("Test",410,235) $edit=GUICtrlCreateEdit("",5,5,400,200) GUICtrlSetStyle($edit,$ES_READONLY) $input=GUICtrlCreateInput("" , 5 ,210,350,20) $b=GUICtrlCreateButton("Send" , 355,210,50,20,$BS_DEFPUSHBUTTON) GUICtrlSetOnEvent(-1 , "_send") GUISetOnEvent($GUI_EVENT_CLOSE,"quit") GUISetState() GUICtrlSetState($input,$GUI_FOCUS) While 1 Sleep(100) $recv=UDPRecv($s,4096,2) If IsArray($recv) Then _GUICtrlEdit_AppendText($edit,StringFormat("[%s:%s] > %s\n" , $recv[1],$recv[2],$recv[0])) WEnd Func quit() UDPShutdown() Exit EndFunc Func _send() $data=GUICtrlRead($input) GUICtrlSetData($input,"") GUICtrlSetState($input,$GUI_FOCUS) UDPSend($d,$data) EndFunc here's a simple example you can even test in on your local machine. BUT! because it uses broadcasting you cannot listen on the same port twice so if you run more than one instances of the script only the first one will recv the data but all of them can send P.S.: you need the latest beta Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now