Skip to content
Snippets Groups Projects
Commit 85fe8311 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

Don McGregor source

parent b0b8515c
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>TcpServer</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>./lib/nblibraries.properties</definitions>
</libraries>
</configuration>
</project>
package tcpserver;
public class ConnectionHandler implements Runnable
{
@Override
public void run()
{
}
}
package tcpserver;
import java.net.*;
import java.io.*;
public class TcpServer {
public static void main(String[] args)
{
try
{
ServerSocket server = new ServerSocket(4567);
while(true)
{
Socket connection = server.accept();
ConnectionHandler handler = new ConnectionHandler();
Thread connectionThread = new Thread(handler);
connectionThread.start();
InputStream is = connection.getInputStream();
OutputStream os = connection.getOutputStream();
PrintWriter pw = new PrintWriter(os);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String clientText = br.readLine();
System.out.println(clientText);
pw.println("Hello from server");
pw.flush();
connection.close();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment