Socket streaming

BlitzMax Forums/BlitzMax Programming/Socket streaming

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.

Hi all.

running into a problem. after i have obtained an ip i cannot connect to it. dunno if its summin i am doing with this code, just wondered if n e one else could try this code, just replace my@... with your msn username:

Global socket:TSocket = CreateTCPSocket();
Global stream:Tsocketstream;
Global ipaddress:String;

If ConnectSocket (socket,HostIp("messenger.hotmail.com"),1863)  Then
	Print "Socket Connected"
	stream = CreateSocketStream(socket);
	If (stream) Then
		Print "stream created";
		WriteLine (stream,"VER 1 MSNP9 CVR0\r\n");
		Print ReadLine(stream);
		WriteLine(stream,"CVR 2 0x0409 win 5.10 i386 MSNMSGR 7.0.0816 MSMSGS my@...");
		Print ReadLine(stream);
		WriteLine (stream,"USR 3 TWN I my@...");
		xx:String = ReadLine(stream);
		Print xx;
	End If
	
	count:Int=0;
	collect:Int=0;
	
	Repeat
		count=count+1;
		If Mid(xx,count,1)=2 Then collect = 1;
		If collect = 1 Then 
			'If Mid(xx,count,1)<> "." Then 
			ipaddress=ipaddress+Mid(xx,count,1);
			'EndIf
		EndIf
	Until Mid(xx,count+1,1)=":"
	
	CloseStream(stream);
	CloseSocket(socket);
	Print ("Connecting to " + ipaddress);
	
	If ConnectSocket (socket,HostIp(ipaddress),1863)
		Print("Connected");
		WriteLine (stream,"VER 1 MSNP8 CVR0\r\n");
		Print ReadLine(stream);
	Else 
		Print("Unable to connect");
	EndIf
	
EndIf

CloseStream(stream);
CloseSocket(socket);


i know code is kinda sloppy but this was only intended as a test, only thing i can think may cause an issue reading the docs is that once its obtained the ip a msn client would connect to the host name of the ip, but cant see how thats different than connecting to the ip

*EDIT - seems i need a way to convert a dotted ip string to an int. value for the createsocket() function