UDP Chat
Übersicht

Felix1307Betreff: UDP Chat |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hi Blitz Basic Community,
Ich hab ein kleines Problem mit meinem Chat. Wenn ich es über den localhost(127.0.0.1) laufen lasse funktioniert es. Aber wenn ich mit Freunden per Internet IP chatten will funktioniert es nicht. Code: [AUSKLAPPEN] Graphics 500,400,16,2
AppTitle "UDP Chat 1.2" SetBuffer BackBuffer() Include "timer.bb" t=createt(1) tflush=createt(2) f=LoadFont("ComicSansMS",14,1) Color 0,200,0 SetFont f ClsColor 0,0,100 Cls port=7000 udp = CreateUDPStream(port) While udp=0 Print "Der Port ist nicht verfügbar." CloseUDPStream udp port=Input("Neuer Port (Standard: 7000): ") udp=CreateUDPStream(port) Wend Repeat controlt() msgip = RecvUDPMsg(udp) If msgip<>0 Then If msgip<>oldip Then WriteByte(udp,Asc("C")) WriteByte(udp,Asc("o")) WriteByte(udp,Asc("n")) WriteByte(udp,Asc("n")) WriteByte(udp,Asc("e")) WriteByte(udp,Asc("c")) WriteByte(udp,Asc("t")) WriteByte(udp,Asc("e")) WriteByte(udp,Asc("d")) oldip=msgip SendUDPMsg udp,oldip,port EndIf End If If oldip<>0 Then IP_String$ = DottedIP(oldip) End If Color 0,0,100 Rect(350,0,150,100,1) Color 0,200,0 Text 350,12,"IP: "+IP_String$ Text 350,24,"Space to write." Text 350,36,"Send to IP - F1" Text 350,48,"Port: "+port Text 350,60,"Port ändern - F2" bytezahl = ReadAvail(udp) If bytezahl<>0 Then For x=1 To bytezahl byte = ReadByte(udp) Write Chr(byte) Next Print "" End If If KeyHit(57) Then FlushKeys msg$=Input("> ") FlushKeys l=Len(msg$) For x=1 To l WriteByte(udp,Asc(Mid(msg$,x,1))) Next SendUDPMsg udp,oldip,port sett(t,0) End If If KeyHit(59) Then FlushKeys .ret IPm$=Input("IP: ") If Instr(IPm$,".")=0 Then Goto ret ;IPm$=Replace(IPm$,".","") oldip=INT_IP(IPm$) IP_String$=DottedIP(oldip) FlushKeys msg$=Input("> ") FlushKeys l=Len(msg$) WriteByte(udp,Asc("C")) WriteByte(udp,Asc("o")) WriteByte(udp,Asc("n")) WriteByte(udp,Asc("n")) WriteByte(udp,Asc("e")) WriteByte(udp,Asc("c")) WriteByte(udp,Asc("t")) WriteByte(udp,Asc("e")) WriteByte(udp,Asc("d")) WriteByte(udp,Asc(":")) WriteByte(udp,Asc(" ")) For x=1 To l WriteByte(udp,Asc(Mid(msg$,x,1))) Next SendUDPMsg udp,oldip,port sett(t,0) End If If KeyHit(60) Then CloseUDPStream udp port=Input("Neuer Port (Standard: 7000): ") udp=CreateUDPStream(port) End If If tgetsecs(t)>1000 Then Goto ending If tgetsecs(tflush)>=2 Then sett(tflush,0):FlushKeys Flip Delay 50 ;Damit Windows nicht so viel ausgelastet wird. Until KeyHit(1) .ending cleartimers() CloseUDPStream udp FreeFont f End 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 Danke schonmal im Vorraus PS Muss man dafür vielleicht einen Server erstellen? EDIT Ich hab eine eigene Timerfunktion, weil es in B3D keine Timerticks gibt, darunter sind die Funktionen: controlt() createt() tgetsecs() sett() cleartimers() |
||
Besucht doch meine Website: http://blbasi.bl.funpic.de/ ![]() |
Felix1307 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ok ich habs das war nur ein Router Problem | ||
Besucht doch meine Website: http://blbasi.bl.funpic.de/ ![]() |
![]() |
Tankbuster |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wenn du das übers Internet machst, musst du einiges beachten. Die Router blocken normalerweise alle nachrichten, die von außen kommen und nicht erwartet werden, also musst du bei mindestens einem PC die Ports des Routers freigeben. Benutz mal die Suchfunktion, ich kann mich dran erinnern, dass ich das schon 2-4 mal erklärt hab.
Suchwörter: UDP Router Firewall hole punching, ect ![]() EDIT: Zu spät |
||
Twitter
Download Jewel Snake! Windows|Android |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group