Hi, ich verstehe das Beispiel von der BB Hilfe nicht ganz.
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics 800, 600 SetBuffer BackBuffer() Inp_Port = 4000 Out_Port = 4001 ip_count = CountHostIPs(GetEnv("localhost"))
Repeat Text 0, 0, "Sample UDP Communications" Text 0, 10, "LOCAL IP:" For i = 1 To ip_count Text 0, 20, DottedIP(HostIP(1)) Next Text 0, 30, "Enter Destination IP#: xxx.xxx.xxx.xxx" Dest_IP$ = NewInput$(Dest_IP$) Text 0, 40, ">" + Dest_IP$ + "|" Flip Cls Until KeyDown(28)
IP = INT_IP(Dest_IP$) udp_rd = CreateUDPStream(Inp_Port) udp_wr = CreateUDPStream(Out_Port) Repeat Text 0, 40, "Starting Chat... Press ESC to quit" byte1 = GetKey() If byte1>0 Then If Byte1 = 13 Then WriteByte(udp_wr, byte1) SendUDPMsg udp_wr, IP, Inp_Port Else drawedSendText$ = drawedSendText$ + Chr(Byte1) WriteByte(udp_wr, byte1) SendUDPMsg udp_wr, IP, Inp_Port EndIf EndIf
IP_rd = RecvUDPMsg(udp_rd)
If IP_rd <> 0 Then Buflen = ReadAvail(udp_rd) If Buflen> 0 Then byte1 = ReadByte(udp_rd) If byte1 <> 13 Then drawedRecText$ = drawedRecText$ + Chr$(byte1) EndIf EndIf EndIf Text 0, 50, drawedSendText$ Text 0, 60, drawedRecText$ Flip Cls Until KeyDown(1)
CloseUDPStream udp_wr CloseUDPStream udp_rd 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 End Function
Function NewInput$(currentText$) localChar = GetKey() If (localChar > 0) And (localChar <> 8 ) Then currentText$ = currentText$ + Chr$(localChar) ElseIf localChar = 8 Then length = Len(currentText) If length > 0 Then currentText = Left(currentText, length - 1) EndIf EndIf Return currentText$ End Function
Meine Frage ist nun, wie die Bytes von dem UDP_wr Stream auf den UDP_rd Stream kommen.
Wie geht das?
Gruß Toasty
|