The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with creating a server.

1 reply on 1 page. Most recent reply: Dec 6, 2002 9:49 AM by Pete Smith

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Pete Smith

Posts: 2
Nickname: jamin2002
Registered: Dec, 2002

Help with creating a server. Posted: Dec 4, 2002 7:53 AM
Reply to this message Reply
Advertisement
Hi,

I am learning Java and I have just got myself confused.

I am trying to create something which would act like a proxy server(I want to demonstrate how a pda would work while on the move) :

The first thing my server does is make an connection with the client;

Then it opens a socket to it,

It will receive text from the client (string), and send the string to another server, this other server will then send another string back to server, then the server will return it to the client.

Here is all that I have so far:

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

public class PDAServer
{
public static void main (String args[])
{
int port = 1027;
ServerSocket myServerSocket = null;

try
{
myServerSocket = new ServerSocket (1027);
}
catch (IOException e)
{
System.out.println("Exception when creating ServerSocket: "+e);
System.exit(1);
}
System.out.println("...started.");

while(true)
{
try
{
Socket MySocket = myServerSocket.accept();
PrintWriter myWriter = new PrintWriter(myServerSocket.getInputStream());
myWriter.println("\n"+pda_String);
myWriter.flush();
messageIn = incoming.getIn();
}
catch (IOException e)
{
System.err.println(e);
}
}
}


if (
pda_String.trim().equals("bye")){
System.out.println("Closing connection to client");
MySocket.close();
}

}
}


I am just baffled by this, If you can send me any tips or links to tutorials pages with an example similar (although I think I may have looked at them all - but I would appreciate anything).

I have looked at a lot of client/server examples but I am just confused at the next stage of receiving a string and sending on to another server.

What is the best way to do this?

Any help will be greatly appreciated.

Regards


Pete Smith

Posts: 2
Nickname: jamin2002
Registered: Dec, 2002

Re: Help with creating a server. Posted: Dec 6, 2002 9:49 AM
Reply to this message Reply
Please remove as I have worked this out - found some good tutorial sites.

Flat View: This topic has 1 reply on 1 page
Topic: Need help with Swing Components Please! :) Previous Topic   Next Topic Topic: NullPointerException & javax.comm

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use