|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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);
}
}
}
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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); } } } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > msn client socket problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|