Jump to content

UDP server help plz


salter
 Share

Recommended Posts

hey there im trying to make a udp server for an app i made, so when they start the app they have to login to the server with an account.

i can make it work on my computer using my ip on both the app and the server but im wondering if you can do the udp bind without knowing the persons ip address and if so how then

any help is appreciated thx

Link to comment
Share on other sites

im wondering if you can do the udp bind without knowing the persons ip address

No, you can't. You have to have the person, whose IP address you don't know, connect to your server which has a static IP address that doesn't change. You could then hard code your server's IP address into the client script and then the client would always know where to look to find the server. If your server is going to change IP addresses frequently, then i would recommend using a web site that the client can connect to and get the IP address of the server. You could then update the site every time the server's IP address changes and the client would therefore always be able to connect to the server. Or you could just set up your own DNS server which is kind of what i just said. :whistle: Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

the server ip isnt changing i just dont know the ip of the client

So have the client connect to the server, not the other way around.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

  • Moderators

how do i do that, i dont understand how the UDP functions work

Deja vu? ... Could have swore I saw that same exact question earlier (the delete original post + re-post same question so it doesn't seem like your desperately bumping kind of bump)? :whistle:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

ok well is this how you do it?

Client:

;;This is the UDP Client
;;Start the server first

; Start The UDP Services
;==============================================
UDPStartup()

; Open a "SOCKET"
;==============================================

$socket = UDPOpen(@IPAddress1, 65532)
If @error <> 0 Then ExitoÝ÷ Ù'«½êÚºÚ"µÍÈÝHQÙXÙÂÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBQÝ

BÈ[ÈHÓÐÒÑUÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBÌÍÜÛØÚÙ]HQ[
YÜÌK
MLÌBYÜ    ÉÝÈ[^]ÌÍÛH
Link to comment
Share on other sites

That is part of it. Why do you want to use UDP anyway? UDP is much harder to use and work with than TCP. TCP transfers data in a connection oriented way with error correction and flow control. Why would you want to use UDP which is connectionless, has no flow control, and relies on the Application Layer of the OSI model for error correction. You have to then write your own error correction routines which would encapsulate each packet with a header and trailer in addition to adding a hash that allows the receiving computer to check if the data it received is in tact. Then if it isn't in tact, you would have to devise a way to have the receiving computer send a message back to the sending computer to have it resend that packet. It just seems like a huge annoyance to me. If you need help, Autoit Smith wrote a great little tutorial on how to use TCP and it is on the forum. I don't recall where, but he wrote it. A search for TCP with his name and him as the original poster would probably yield the correct topic fairly quickly.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

  • 2 weeks later...

ok so i run this server on my friends computer:

UDPStartup()

; Bind to a SOCKET
;==============================================
$socket = UDPBind(@ipaddress1, 65532)
If @error <> 0 Then Exit
$n = 0
While 1
$data = UDPRecv($socket, 50)
 $CheckData = StringSplit($data, "|")
      If Not @Error Then
         For $x = 1 to $Accounts[0]
            $AccRecord = StringSplit($Accounts[$x], "|")
            If Not @Error Then
               If $CheckData[1] = $AccRecord[2] And $CheckData[2] = $AccRecord[3] Then
                  $Exist = 1
MsgBox(64,"User", "User Exists")
                  ExitLoop
               Else
                  $Exist = 0      
MsgBox(64,"User", "User doesnt Exists")  
               EndIfoÝ÷ Ù©Ý¢y²r©º×«»§¶'§µ«­¢+ÙUAMÑÉÑÕÀ ¤((ì=Á¸ÅÕ½ÐíM=
-PÅÕ½Ðì(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô((ÀÌØíͽ­ÐôUA=Á¸ ÅÕ½Ðí5äÉ¥¹Ì%@ÉÍÌ!ÉÅÕ½Ðì°ØÔÔÌȤ)%ÉɽȱÐìÐìÀQ¡¸á¥Ð((ÀÌØí¸ôÀ)]¡¥±Ä($ÀÌØí    ½Ñ½Õ¹ÐôU%
ÑɱI ÀÌØí½Õ¹Ð¤($ÀÌØí    ½ÑAÍÌôU%
ÑɱI ÀÌØíAÍ̤($ÀÌØíµÍôU%Ñ5Í ¤(%%ÀÌØíµÍôÀÌØí
¡¬Q¡¸($$ÀÌØíÍÑÑÕÌôUAM¹ ÀÌØíͽ­Ð°U%
ÑɱI ÀÌØí½Õ¹Ð¤µÀìÅÕ½ÐíðÅÕ½ÐìµÀìU%
ÑɱI ÀÌØíAÍ̤µÀìÅÕ½ÐíðÅÕ½ÐìµÀìÅÕ½Ðí=,ÅÕ½Ðì¤($%%ÀÌØíÍÑÑÕÌôÀQ¡¸($$%5Í ½à À°ÅÕ½ÐíII=HÅÕ½Ðì°ÅÕ½ÐíÉɽÈÝ¡¥±½¹¹Ñ¥¹ÅÕ½ÐìµÀìÉɽȤ($$%á¥Ð($%¹%($%M±À ÄÀÀÀ¤($$ÀÌØíIÍÁ½¹ÍôUAIØ ÀÌØíͽ­Ð°ÔÀ¤($%%ÀÌØíIÍÁ½¹ÍôÅÕ½ÐíÁÑÅÕ½ÐìQ¡¸($$%U%MÑMÑÑ¡M]}!%¤($$%5¥¹U$ ¤($%¹%($%%ÀÌØíIÍÁ½¹ÍôÅÕ½Ðí¹¥ÅÕ½ÐìQ¡¸($%¹%($%%ÀÌØíIÍÁ½¹ÍôÅÕ½Ðíá¥ÐÅÕ½ÐìQ¡¸($$%á¥Ð($%¹%(%¹%

i can get it working if i run bot the server and the client on my computer using the "127.0.0.1" as the ip but when i try and connect to the server when its running on a diff computer it does nothing at all.

anyone know whats wrong?

Link to comment
Share on other sites

You didn't explain where this other computer you are connecting from is located. Is it on a LAN, on the other side of the country, or what? I suspect that you are using the wrong IP to connect. If not, and you are connecting through the internet and through a router, you may not have port forwarding enabled.

I don't know what else to say, other than you are probably not using the correct IP to connect. If you are on a LAN, connect using the local area network address. If it is a WAN, you have to connect using the WAN IP address.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...