UDP Problem !!!
Übersicht

![]() |
juse4proBetreff: UDP Problem !!! |
![]() Antworten mit Zitat ![]() |
---|---|---|
hi leutz,
ich hab mal nen server und nen client mit UDP geschrieben verbindet sich aber nicht richtig: ;server Graphics 800,600,16,2 AppTitle "server" Global x1,y1,dir1 Global x2,y2,dir2 Global x3,y3,dir3 Global x4,y4,dir4 IN_stream=CreateUDPStream(7750) OUT_stream=CreateUDPStream(7751) While Not KeyHit(1) If IN_stream Text 5,200,"xxx" x1=ReadInt ( IN_stream ) y1=ReadInt ( IN_stream ) dir1=ReadInt ( IN_stream ) anim1=ReadInt ( IN_stream ) msg1=ReadString ( IN_stream ) Text 5,145,msg1 EndIf Text 5,5,"PLAYER 1 x: "+x1+" PLAYER 1 dir: "+dir1 Text 5,25,"PLAYER 1 y: "+y1 Text 5,305,"IN: "+UDPStreamPort(IN_stream) Text 5,325,"OUT: "+UDPStreamPort(OUT_stream) Flip Cls Wend End ;client AppTitle "client" Global IPs$ IPs$=Input("IP: ") IP%=Int(IPs$) IN_stream=CreateUDPStream();7752) OUT_stream=CreateUDPStream();7752) SetBuffer BackBuffer() While Not KeyHit(1) If OUT_stream WriteInt OUT_stream,x1 WriteInt OUT_stream,y1 WriteInt OUT_stream,dir1 WriteInt OUT_stream,anim1 WriteString OUT_stream,"PLAYER 1: ON" SendUDPMsg OUT_stream,IP;,7750 Text 5,5,"xxx" EndIf If KeyDown(200) Then y1=y1-1 If KeyDown(208) Then y1=y1+1 If KeyDown(205) Then x1=x1+1 If KeyDown(203) Then x1=x1-1 Text x1,y1,"Player 1" Flip Cls Wend End benötige HILFE ...heul... ...bin verzweifelt... |
||
Portfolio |LinkedIn |XING |
![]() |
the FR3AK |
![]() Antworten mit Zitat ![]() |
---|---|---|
...ein Post reicht! ![]() Und Benutz den Code Button wenn du Codes einfügst^^ Code: [AUSKLAPPEN] Code
|
||
![]() |
Tankbuster |
![]() Antworten mit Zitat ![]() |
---|---|---|
Also,... zunächst ist mir aufgefallen, dass du 2 Streams hast! Das steht in dem Tut so, aber einer reicht auch!^^
Bist du sicher, dass du die richtige IP eingegeben hast! Da musst du nämlich nicht einfach "127.0.0.1" eingeben! *EDIT* Ich sehe überhaupt net, dass du eine IP angegeben hast! |
||
Twitter
Download Jewel Snake! Windows|Android |
![]() |
Hummelpups |
![]() Antworten mit Zitat ![]() |
---|---|---|
Weil die IP auch per Input abgefragt wird. | ||
blucode - webdesign - Ressource - NetzwerkSim
BlitzBasic 2D - BlitzMax - MaxGUI - Monkey - BlitzPlus |
![]() |
Tankbuster |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ups, hap ich glatt übersehen!
Aber du musst die Ip mittels einer Funktion in einen Integear (falls das so geschrieben wird) xD verwandeln! mom... Hier ist die Funktion: Zitat: Function INT_IP(IP$)
a1=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a2=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a3=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a4=Int(IP$) Return (a1 Shl 24) + (a2 Shl 16) + (a3 Shl 8 ) +a4 End Function Im Code kannst du das dann so schreiben: Zitat: alteIP$=Input("lol")
richtigeIP=INT_IP(alteIP$) |
||
Twitter
Download Jewel Snake! Windows|Android |
![]() |
Hummelpups |
![]() Antworten mit Zitat ![]() |
---|---|---|
Zitat: alteIP$=Input("lol")
richtigeIP=INT_IP(alteIP$) Lol, alt ist die IP nich und richtig ist auch die eingegebene IP, wenn dann benenn die Variablen zu StringIP und IntIP. Und nein es wird nicht Integear geschrieben ^^ Integer. Ganz leicht. IMurDOOM[/quote] |
||
blucode - webdesign - Ressource - NetzwerkSim
BlitzBasic 2D - BlitzMax - MaxGUI - Monkey - BlitzPlus |
![]() |
juse4proBetreff: no |
![]() Antworten mit Zitat ![]() |
---|---|---|
![]() ;hier nochmal die verbesserten Programme Code: [AUSKLAPPEN] Graphics 800,600,16,3 AppTitle "server" Global x1,y1,dir1 Global x2,y2,dir2 Global x3,y3,dir3 Global x4,y4,dir4 stream=CreateUDPStream(7750) SetBuffer BackBuffer() While Not KeyHit(1) If stream Text 5,200,"xxx" ;WriteInt(client1,x2) ;WriteInt(client1,y2) x1=ReadInt ( stream ) y1=ReadInt ( stream ) dir1=ReadInt ( stream ) anim1=ReadInt ( stream ) msg1=ReadString ( stream ) Text 5,145,msg1 EndIf Text 5,5,"PLAYER 1 x: "+x1+" PLAYER 1 dir: "+dir1 Text 5,25,"PLAYER 1 y: "+y1 Text 5,45,"PLAYER 2 x: "+x2+" PLAYER 2 dir: "+dir2 Text 5,65,"PLAYER 2 y: "+y2 Text 5,305,"PORT: "+UDPStreamPort(stream) Flip Cls Wend End und hier der client Code: [AUSKLAPPEN] AppTitle "client" Global IP Global alteIP$ Function INT_IP(IP$) a1=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a2=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a3=Int(Left(IP$,Instr(IP$,".")-1)):IP$=Right(IP$,Len(IP$)-Instr(IP$,".")) a4=Int(IP$) Return (a1 Shl 24) + (a2 Shl 16) + (a3 Shl 8 ) +a4 End Function alteIP$=Input("IP: ") IP=INT_IP(alteIP$) stream=CreateUDPStream() SetBuffer BackBuffer() While Not KeyHit(1) If stream WriteInt stream,x1 WriteInt stream,y1 WriteInt stream,dir1 WriteInt stream,anim1 WriteString stream,"PLAYER 1: ON" SendUDPMsg stream,IP,7750 Text 5,5,"xxx" EndIf If KeyDown(200) Then y1=y1-1 If KeyDown(208) Then y1=y1+1 If KeyDown(205) Then x1=x1+1 If KeyDown(203) Then x1=x1-1 Text x1,y1,"Player 1" Flip Cls Wend End WICHTIG WICHTIG!! brauch hilfe... |
||
Portfolio |LinkedIn |XING |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group