Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Package errors with my Server Socket java code

$
0
0
I am getting the error that the "so" package does not exist and another error stating cannot find symbol for "outputToClient.writeBytes(...)"

// TCP Server Program based on a sample from Kurose, Computer Networking
// This program inputs a string from a client, displays it, and then
// returns a string to the client. 

import java.io.*;
import java.net.*;
import java.util.Scanner; 


class IT420Server {

	public static void main (String args[]) throws Exception
	{
		
		InetAddress ip;
		String[] logmessages= new String[5]; 
		String clientSentence;
		
	
		System.out.println("listening...");
		
		ServerSocket socket = new ServerSocket(62789);
		Socket so = socket.accept();
		/*
		DataInputStream inputFromClient= new DataInputStream(
		connectionSocket.getInputStream());
		DataOutputStream outToClient = new DataOutputStream
			(connectionSocket.getOutputStream());
	*/
	
	
		
	try{
		while (true) {

		BufferedReader inputFromClient= new BufferedReader(new 
		so.getInputStream()); 
		BufferedReader outToClient= new BufferedReader(new 
		so.getOuputStream());	

			ip=InetAddress.getLocalHost();  
			
			clientSentence = inputFromClient.readLine();
			System.out.println("FROM " +ip+": "+ clientSentence);
		
			// Send message to client - must have \n
			outToClient.writeBytes("Hello, client \n");
			System.out.println ("TO CLIENT: Hello, client");

			//if(outToClient.writeBytes()=="END")
				so.close();
		}
		}catch(SocketException e){
		
			System.out.println("there is a problem with your socket");
		}

	}
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>