direct chat prog

Blitz3D Forums/Blitz3D Programming/direct chat prog

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm trying to send direct messages using UDP from computer to computer. I don't want it to pass through a server computer, instead I want it to link directly to another IP to interact with. I don't want to use direct play. I have experience in networking, etc, i just haven't written a network program before, but I do know how most of it works, so don't dumb down the explanations of why this fails to operate. This is what I have so far:
Type Client
	Field ip_d$ ; the dotted ip (so that i don't have to calculate it every time i want to use it)
	Field ip_i  ; the integer ip (see above explanation)
End Type

Locate 0,15

Global stream = CreateUDPStream(7000)
Global inputStream$
loadClients()

While Not KeyDown(1)
	
	Locate 0,15
	updateClients
	getInput
	
Wend

Function loadClients()
	
	s$ = CommandLine$()
	Print s$
	x1=1 : x2=1
	
	c.Client = Null
	
	Repeat
		
		char$ = Mid$( s$, x1, 1 )
		Select( char$ )
		Case ",":
			If c <> Null
				n = CountHostIPs(c\ip_d$)
				c\ip_i = HostIP(1)
			EndIf
			
			c.Client = New Client
			Print ""
			
		Default:
			c\ip_d$ = c\ip_d$ + char$
			Write char$
		
		End Select
		
		x1=x1+1
		
	Until char$ = ""
	
	
End Function

Function updateClients()
	
	ip$ = RecvUDPMsg%( stream )
	Print ip$ + ReadLine$(stream)
	
End Function

Function getInput()

	k = GetKey%()
	If k <> 13 And k > 0
		inputStream$ = inputStream$ + Chr$( k )
		Locate 0,0
		Print "me: "+inputStream
	ElseIf k = 13
		WriteLine(stream,inputStream$)
		For c.Client = Each Client
			WriteLine( stream, "127.0.0.1: "+inputStream$ ) ;don't worry about the "127.0.0.1" part, it will change
			SendUDPMsg stream, c\ip_i, 7000
		Next
		inputStream$ = ""
	EndIf
	
End Function


The part that uses CommandLine$() and the loadClients() things split up dotted ip addresses in the command line for every client. I'm just using ",127.0.0.1" for testing. The comma has to be before every ip for it to work. The idea behind the command line parameters is that i could then create each instance as a "chat window" that could be loaded from a master program thing. You may have to open up port 7000 in your firewall for it to work.