Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 16th, 2004, 11:12 PM
fony fony is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 fony User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 30 sec
Reputation Power: 0
msn client socket problem

hi there when i run this code i get the connection
but when i send the command "VER 0 MSN4 MSN5 MSN6 MSN7 MSN8 MSN9 CVR0 \r\n" the server replies with
"VER 0 CVR0" it doesn't reply with the protocol version
can any one tell me wats the problem , thanx in advance
Code:
import java.net.*;
import java.io.*;

public class tcpClient {    
    
    public static void main(String[] args) {

	int port = 1863;
	String server ="messenger.hotmail.com";
	Socket socket = null;
	String lineToBeSent;
	BufferedReader input;
	PrintWriter output;
	int ERROR = 1;
	
	// connect to server
	try {
	    socket = new Socket(server, port);
	    System.out.println("Connected with server " +
				   socket.getInetAddress() +
				   ":" + socket.getPort());

	}
	catch (UnknownHostException e) {
	    System.out.println(e);
	    System.exit(ERROR);
	}
	catch (IOException e) {
	    System.out.println(e);
	    System.exit(ERROR);
	}

	try {
	    input = new BufferedReader(new InputStreamReader(System.in));
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
DataOutputStream outToServer = new DataOutputStream(socket.getOutputStream());
	    output = new PrintWriter(socket.getOutputStream(),true);

	    outToServer.writeBytes ("VER 0 MSN4 MSN5 MSN6 MSN7 MSN8 MSN9 CVR0 \r\n");

    String line =  inFromServer.readLine();
System.out.println("The ServerReply is :"+line);
    outToServer.writeBytes("CVR 2 0x0409 win 2000 i386 MSNMSGR 5.0.0544 MSMSGS URL\r\n");

    line = inFromServer.readLine();
    System.out.println("The ServerReply is :"+line);
	}
	catch (IOException e) {
	    System.out.println(e);
	}

	try {
	    socket.close();
	}
	catch (IOException e) {
	    System.out.println(e);
	}
    }    
}

Reply With Quote
  #2  
Old February 22nd, 2007, 01:09 AM
msierks msierks is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 2 msierks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 22 sec
Reputation Power: 0
Solution To Your Problem !!!

Replace: outToServer.writeBytes ("VER 0 MSN4 MSN5 MSN6 MSN7 MSN8 MSN9 CVR0 \r\n");


With: output.write("VER 0 MSN4 MSN5 MSN6 MSN7 MSN8 MSN9 CVR0 \r\n");

You will also be able to delete some other code to but you can figure that out on your own

Reply With Quote
  #3  
Old June 6th, 2007, 09:18 PM
msierks msierks is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 2 msierks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 22 sec
Reputation Power: 0
This Is a Working Connection With THe Messnger Server

import java.net.*;
import java.io.*;

/**
* @author (Michael Sierks)
* @version (20070606)
*/
public class Messenger_Client
{
public static void main(String args[])
{
//specify ip and port
String InternetProtocol = "messenger.hotmail.com";
int PortNumber = 1863;

// create socket
Socket MessengerSocket;

//input and output streams
BufferedReader receive = null;
PrintWriter send = null;

//making the connection and communicating
try
{
MessengerSocket = new Socket(InternetProtocol,PortNumber);
System.out.println("Connected");
send = new PrintWriter(MessengerSocket.getOutputStream(), true);
receive = new BufferedReader(new InputStreamReader(MessengerSocket.getInputStream() ));
}
catch(UnknownHostException e)
{
System.out.println(e);
System.exit(1);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
send.println("VER 0 MSN4 MSN5 MSN6 MSN7 MSN8 MSN9 CVR0 \r\n");
System.out.println("received: " + receive.readLine());
}
catch(IOException e)
{
System.out.println(e);
System.exit(1);
}
}
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > msn client socket problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT