Help with client server chat 1

Hi,
I have to create small multithreaded client/server. chat program. Server and client have to exchange messages using input boxes until user types QUIT. I did most of it(I think) but it seems that server does not receives client messages and input boxes are displayed only once. I can�t figure out what is the problem. Here is what I did .I know it�s not easy to understand somebody else�s code, but if anybody have some spare time?
this is just a server part, client is in second posting
SERVER.JAVA
import java.io.*;
import java.net.*;
import java.lang.*;
import javax.swing.*;
public class Server
final int SBAP_PORT = 5555;
//constructor
public Server(){
//set up server socket
ServerSocket ss = null;
try {
ss = new ServerSocket(SBAP_PORT);
} //end try
catch (Exception e) {
System.out.println("Could not create socket: Exception " + e);
System.exit(0);
} //end catch
//chat with the client until user break the connection or enters QUIT
try {
while(true) {
System.out.println("Server: Waiting for client to connect ...");
Socket currentSocket = ss.accept();
//create a new thread for each connection
new ServerThread(currentSocket);
} //end while
} //end try
catch (Exception e) {
System.out.println("Fatal server error: " + e);
}//end catch
}//end constructor
//inner class ServerThread to handle individual client connections
private class ServerThread extends Thread {
private Socket sock;
private InputStream in=null;
private OutputStream out=null;
private BufferedReader reader = null;
private PrintWriter writer = null;
//constructor
public ServerThread(Socket sock) {
try{
this.sock=sock;
System.out.println("Server: Client connection established");
start();
}//end try
catch (Exception e){}
}//end constructor
public void run() {
try{
in = this.sock.getInputStream();
out =this.sock.getOutputStream();
reader = new BufferedReader(new InputStreamReader(in));
writer = new PrintWriter(out);
while(true) {
String server_response = JOptionPane.showInputDialog(null,"Server Response");
System.out.println("Sending: " + server_response);
writer.println(server_response);
writer.flush();
String line = reader.readLine(); //receives client request
if (line == null || line.equals("QUIT"))
System.out.println("No data received");
else
System.out.println("Received: " + line);
}//end while
}//end try
catch (Exception e) {
System.out.println("Connection to current client lost.");
finally {
try {
sock.close();
}//end try
catch (Exception e) {}
}//end finally
}//end run
}//end inner class ServerThread
//main starts
public static void main(String[] args) {
new Server();
}//end main()
}//end class Server

http://forum.java.sun.com/thread.jspa?threadID=574466&messageID=2861516#2861516

Similar Messages

  • Help with client server chat2

    Hi aggain,
    And here is my Client part of program
    Server part is in topic "help with client server1
    CLIENT.JAVA
    import java.io.*;
    import java.net.*;
    import java.lang.*;
    import javax.swing.*;
    public class Client {
    private static int SBAP_PORT = 5555;
    private static String server = "localhost";
    public static Socket socket = null;
    //main starts
    public static void main(String[] args) {
    try { //handle broken connection
    //set up connection to server, input, output streams
    try {
    socket = new Socket(server, SBAP_PORT);
    // handle wrong host/port errors
    catch (UnknownHostException e) {
    System.out.println("Unknown IP address for server.");
    System.exit(0);
    } //end catch UnknownHost
    catch (IOException ex) {
    System.out.println("No server found at specified port.");
    System.exit(0);
    } //end catch IOException
    catch (Exception exc) {
    System.out.println("Error :" + exc);
    System.exit(0);
    } //end cath Exception exc
    InputStream input = socket.getInputStream();
    OutputStream output = socket.getOutputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(input));
    PrintWriter writer = new PrintWriter(output);
    while (true) {
    String client_in = JOptionPane.showInputDialog(null, "Client Request");
    System.out.println("Sending: " + client_in);
    writer.print(client_in);
    writer.flush();
    //read server entry and dispay
    String response = reader.readLine();
    if (response == null || response.equals("QUIT"))
    System.out.println("No data received");
    else
    System.out.println("Receiving: " + response);
    } //end try
    catch (IOException e) {
    System.out.println("Connection with server broken:" + e);
    System.exit(0);
    } //end catch IOException
    catch (Exception exp) {
    System.out.println("Error :" + exp);
    System.exit(0);
    } //end catch exp
    }//end main()
    }//end class Client

    http://forum.java.sun.com/thread.jspa?threadID=574466&messageID=2861516#2861516

  • Help with client/server

    Hi guys, ive been developing a scrabble application lately, i have finished most parts of the game itself, so i decided to include the client/server (playing over LAN.)
    I have been able to make some features work like chat, update scores, switch turns.
    Now, i want to make a move so when a player plays, the tiles he drops on the board would update on the other player's game screen. I created a method and i have tried it in the normal game class(not client/server) and it works. But after coming up wiv a logic to send message to update the tiles, it doesnt work. I have attached pieces of the code pertaining to my problem.
    // Method to transfer the tiles (update the board with the tiles)
    //LetterBag class:
       public void transferTile(int tileindex, int cellindex, JPanel cell[]){
            for(int i=0;i<cell.length;i++){
                if(i==cellindex){
    // letterTile class contains all the tiles with each having its own index value (letterTile extends JLabel)
    //tiles is a Vector where i stored all the gameTiles.
                letterTile lt=(letterTile) tiles.elementAt(tileindex);
                    cell.add(lt);
    removeTile(tileindex);
    Multiplayerboard class:
    //Where i send the message to the server
    for(int i=0;i<ogaTile.size();i++){
    Vector v=(Vector)ogaTile.elementAt(i);
    int tindex=(Integer)v.elementAt(0);
    int cellindex=(Integer)v.elementAt(1);
    client.sendMessage("#-TRANSFERTILES-"+tindex+"-"+cellindex+"-*");
    //Tried printing out the above code and it prints out the right values
    Multiplayerclient class:
    lbag=new LetterBag();
    //multiplayer = new MultiplayerBoard(Player, this, chatter);
    //This is where the message is interpreted
    if (line.startsWith("#-TRANSFERTILES-")) {
    //anlyzer is the message string ( message line spits at"-")
    int x=Integer.parseInt(analyzer[0]);
    int y=Integer.parseInt(analyzer[1]);
    //multiplayer is instance of MultiplayerBoard class
    //cell is the gameboard panel in MultiplayerBoard class
    multiplayer.lbag.transferTile(x, y, multiplayer.cell);
    The problem is when i play, the game other client's application update the board with the tiles. I dont know where the problem is coming from maybe the logic or something else. Please any help/suggestion is really needed.

    dnt worry..
    jst solved it.. was an error on ma part

  • Desperately need some help with client-server java programming

    Hi all,
    I'm new to client server java programming. I would like to work on servlets and apache tomcat. I installed the apache tomcat v 5.5 into my machine and i have sun java 6 also. I created a java applet class to be as a client and embed it into an html index file, like this:
    <applet code="EchoApplet.class" width="300" height="300"></applet>However, when I try to run the html file on the localhost, it print this error: classNotFoundException, couldn't load "EchoApplet.class" class. On the other hand, when I open the index file on applet viewer or by right clicking, open with firefox version 3, it works.
    I thought that the problem is with firefox, but after running the applet through the directory not the server, i found that the problem is not any more with firefox.
    Can anyone help me to solve this problem. I'm working on it for 5 days now and nothing on the net helped me. I tried a lot of solutions.
    Any help?

    arun,
    If the browser is going to execute $myApplet, first it must get the $myApplet.class from the server, right?
    So it follows that:
    1. $myApplet.class must be acessible to server, and
    2. the server must know exactly where to find $myApplet.class
    So, the simplest solution is to is put the $myApplet.class in the same directory as the HTML file which uses it... then your applet tag is simple:
      <applet height="200" width="400" code="$myApplet.class" ></applet>* The height & width attributes are required
    * Note the +.class+ is required in the code attribute (a common mistake).
    * This works uniformly (AFAIK) accross all java-enabled browsers.
    * There are incompatibilities with the codebase attribute. Poo!
    Cheers. Keith.

  • Help with Client/Server communication

    Im working on a project for university, and one aspect of it is downloading files from a remote computer.
    The majority of my project so far has been using RMI only, for browsing the remote computer, deleting files, renaming files, creating new directories and searching for files. All of this is done via a GUI client, with a server running on the server machine.
    Ive now reached the part where I'll need to implement the downloading of files. I want the user to select a file from within the GUI and click download, and get it off the server.
    I dont need any help with event handlers or getting the contents of the remote computer or anything of that sort.
    Consider when I have the name of the file that I want to download from the client.
    Im having trouble understanding how exactly its going to work. Ive seen examples of file transfer programs where the user types in the name of the file in the command line which they want to download. But my implementation will differ.
    Every time the user clicks the button, I have to send to the server the name of a different file which will need to be downloaded.
    I imagine in the event handler for the Download button I'll be creating a new socket and Streams for the download of the file that the user wants. But how am I to send to the client a dynamic file name each time when the user tries to download a different file?
    I am a bit new at this, and Ive been searching on the forums for examples and Ive run through them, but I think my situation is a bit different.
    Also, will RMI play any part in this? Or will it purely be just Socket and Streams?
    I'll also develop an Upload button, but I imagine once I get the Download one going, the Upload one should be much harder.
    Any ideas and help would be appreciated.

    Hi
    I'm no RMI expert... and I did not understand your question very well....
    I think you should do this procedure:
    you should send a request for the file from the client to the server . then a new connection between the two machines should be made which will be used to send the file.
    by using UDP you will achive it quite nicely...
    //socket - is your TCP socket  you already use on the client...
    //out - socket's output stream
    byte [] b=new String("File HelloWorld.java").getBytes();
    // you should use a different way for using this rather than using strings...
    out.write(b);
    DatagramSocket DS=new DatagramSocket(port);
    DS.recieve(packet); //the data is written into the packet...on the server side you should...
    //socket - is your TCP socket  you already use on the server...
    //in - socket's input stream
    byte [] b=new byte[256];
    out.read(b);
    /*Here you check what file you need to send to the client*/
    DatagramSocket DS=new DatagramSocket(server_port);
    byte [] data=//you should read the file and translate it into bytes and build a packet with them
    DS.send(packet); //the data is in the packet...This way the server sends the required file to the client .....
    I hope it will help, otherwise try being clearier so I could help you...
    SIJP

  • Help with client server program!

    OK, I've gotten this far on my own, but now I need a little help. My program is supposed to allow a client to type in a file name in a JTextField and have the server return the file contents. Someone please let me know where I have erred. Below is the code for server.java and client.java. Thanks for your help!
    import java.io.*;
    import java.net.*;
    public class Server
    private BufferedWriter output;
    private BufferedReader input;
    private Socket connection;
    String str;
    public void runServer ( )
    int counter = 0;
    try
    ServerSocket server = new ServerSocket ( 8189 );
    while ( counter < 2 )
    connection = server.accept ( );
    getStreams ( );
    processConnection ( );
    closeConnection ( );
    counter++;
    catch ( IOException ioException )
    ioException.printStackTrace ( );
    private void getStreams ( ) throws IOException
    output = new BufferedWriter ( new OutputStreamWriter ( connection.getOutputStream ( ) ) );
    output.flush ( );
    input = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ) ) );
    private void processConnection ( ) throws IOException
    String fileName = input.readLine ( );
    File file = new File ( fileName );
    BufferedReader fileInput = new BufferedReader ( new InputStreamReader
    ( new FileInputStream ( file ) ) );
    BufferedWriter writer = new BufferedWriter ( new FileWriter ( file ) );
    while ( ( str = fileInput.readLine ( ) ) != null )
    output.write ( str );
    output.newLine ( );
    output.flush ( );
    writer.close ( );
    private void closeConnection ( ) throws IOException
    output.close ( );
    input.close ( );
    connection.close ( );
    public static void main ( String [ ] args )
    Server application = new Server ( );
    application.runServer ( );
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame
    private JTextField enterField;
    private JButton saveButton;
    private JTextArea displayArea;
    private BufferedWriter output;
    private BufferedReader input;
    private String message = "";
    private Socket connection;
    public Client ( )
    super ( "Client" );
    Container container = getContentPane ( );
    JPanel panel = new JPanel ( );
    JLabel displayLabel = new JLabel ( "Enter file name to retrieve: " );
    panel.add ( displayLabel );
    enterField = new JTextField ( 10 );
    enterField.setEnabled ( false );
    enterField.addActionListener (
    new ActionListener ( )
    public void actionPerformed ( ActionEvent event )
    sendFile ( event.getActionCommand ( ) );
    panel.add ( enterField );
    saveButton = new JButton ( "Save Changes" );
    saveButton.addActionListener (
    new ActionListener ( )
    public void actionPerformed ( ActionEvent event )
    sendFile ( event.getActionCommand ( ) );
    panel.add ( saveButton );
    container.add ( panel, BorderLayout.NORTH );
    displayArea = new JTextArea ( );
    container.add ( new JScrollPane ( displayArea ), BorderLayout.CENTER );
    setSize ( 500, 400 );
    setVisible ( true );
    public void runClient ( )
    try
    connection = new Socket ( InetAddress.getLocalHost ( ), 8189 );
    getStreams ( );
    processConnection ( );
    closeConnection ( );
    catch ( EOFException eofException )
    System.out.println ( "Server terminated connection" );
    catch ( IOException ioException )
    ioException.printStackTrace ( );
    private void getStreams ( ) throws IOException
    output = new BufferedWriter ( new OutputStreamWriter ( connection.getOutputStream ( ) ) );
    output.flush ( );
    input = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ) ) );
    private void processConnection ( ) throws IOException
    enterField.setEnabled ( true );
    message = ( String ) input.readLine ( );
    while ( message != null )
    displayArea.append ( message + "\n" );
    private void closeConnection ( ) throws IOException
    output.close ( );
    input.close ( );
    connection.close ( );
    private void sendFile ( String message )
    try
    output.write ( message );
    output.flush ( );
    catch ( IOException ioException )
    displayArea.append ( "\nError writing" );
    public static void main ( String [ ] args )
    Client application = new Client ( );
    application.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
    application.runClient ( );

    Well, where do YOU think you erred?
    Are you getting any error messages? If so, what are they?
    Are you getting any behavior other than what you expected? If so, what behavior did you expect, and what behavior are you getting instead?
    I can't speak for the others, but I'm much more inclined to help if you had at least said something like...
    "If I type in the name of a file that doesn't exist, a JPanel pops up with nothing written in it. This is behavior I want. If I type in the name of a file that does exist, a JPanel should pop up with the contents of that file, but unfortunately, it thinks there's nothing in the file. I know my program can at least find the file because I added a routine to write the name of the file within the JPanel if it can find the file."
    It is much easier for me to just write my own program to display the contents of a file, than it is for me to read your mind and discover what problems YOU are having with it.

  • Multithreading issue with Client/Server chat program

    In a nutshell, I just recently starting attempting to use Sockets and decided I wanted to give a go at a chat program. I have some experience with threads but I know little about how to find and fix multithreading issues. I think this is my problem right now since I am deadlocking while connecting and disconnecting client-side ... and updates about connection status of a client are not always displaying correctly server-side.
    [ Code Snippet|http://snipplr.com/view/15206/clientserver-chat-program/]
    Thanks for the help

    NOTE: all catch clauses have been omitted for clarity. They all just perform System.err.println() with the msg embedded
    Very valid point. I cut out the GUIs and just tried having the Server/Client communicate. I am still having concurrency issues. This is my first attempt at synchronized methods and locking objects so go easy on me if I did something(s) noob =D
    public class MySocket
        public static final String QUIT = "~~QUIT~~";
        private ObjectOutputStream out;
        private ObjectInputStream in;
        private Socket conn;
        public MySocket(String ip)
            obsList = new ArrayList<IClientObs>();
            try
                conn = new Socket(ip, 5000);
                if (conn.isConnected())
                    out = new ObjectOutputStream(conn.getOutputStream());
                    in = new ObjectInputStream(conn.getInputStream());
        public synchronized String nextMsg()
            String msg = "";
            try
                synchronized(in)
                    msg = (String)in.readObject();
                    notify(msg);
            return(msg);
        public synchronized boolean sendMsg(String msg)
            boolean sentMsg = false;
            try
                synchronized(out)
                    if (out != null)
                        out.writeObject(msg);
                        out.flush();
                        sentMsg = true;
            return(sentMsg);
        public synchronized void closeConn()
            try
                synchronized(this)
                    sendMsg(QUIT);
                    conn.close();
                    out.close();
                    in.close();
        public synchronized Socket getConn()
            return(conn);
        public synchronized ObjectOutputStream getOutStream()
            return(out);
        public synchronized ObjectInputStream getInStream()
            return(in);
       //Observer Pattern implemented below   
    public class Server extends Thread
        public static final int MAX_CLIENTS = 2;
        public static final String QUIT = "~~QUIT~~";
        private ServerSocket server;
        private ArrayList<ConnClient> conns;
        private int connCount;
         * Constructor for objects of class Server
        public Server()
            conns = new ArrayList<ConnClient>();
            obsList = new ArrayList<IServerObs>();
            connCount = 0;
        public void startNow()
            this.start();
        public void run()
            runServer();
        public synchronized void runServer()
            try
                setup();
                while (true)
                    waitForConn();
                    processComms();
        private synchronized void setup() throws IOException
            server = new ServerSocket(5000);
            notify("Server initialized.\n");
        private synchronized void waitForConn() throws IOException
            if (connCount < MAX_CLIENTS)
                notify("Waiting for connection...\n");
                Socket conn = server.accept();
                if (conn.isConnected())
                    conns.add(new ConnClient(conn));
                    notify("Client connected @ '" + conns.get(connCount).getIP() + "'.\n");
                    connCount++;
            else
                notify("Connection request rejected; max connections have been reached.\n");
        private synchronized void processComms() throws IOException, ClassNotFoundException
            //Receive any msgs sent by clients and forward msg to all clients
            for(ConnClient rcvClient : conns)
                String msg = rcvClient.nextMsg();
                //if client quit, then close connection and remove it from list
                if (msg.equals(QUIT))
                    notify("Client disconnected @ '" + rcvClient.getIP() + "'.\n");
                    rcvClient.closeConn();
                    conns.remove(rcvClient);
                    connCount--;
                else
                    for(ConnClient sndClient : conns)
                        sndClient.sendMsg(msg);
        public synchronized void shutdown()
            try
                server.close();
                for(ConnClient client :conns)
                    client.closeConn();
       //Observer Pattern implemented below
    }I also found another issue that I haven't thought up a way to deal with yet. When the user starts the program the follow line is executed "conn = server.accept();" which halts execution
    on that thread until a connection is established. What if the user wants to stop the server before a connection is made? The thread keeps running, waiting for a connection. How do I kill this thread?
    On this last issue (I figured by adding the follow code to my action listener inside of my server gui I could stop the thread safely but it's no good so far)
    public void actionPerformed(ActionEvent e)
            Object src = e.getSource();
            if (src == strBtn)
                if (server == null)
                    strBtn.setEnabled(false);
                    stpBtn.setEnabled(true);
                    server = new Server();
                    server.addObserver(this);
                    server.start();
                else
                    console.append("Console: Server is alread initiated.\n");
            else if (src == stpBtn)
                synchronized(server)
                strBtn.setEnabled(true);
                stpBtn.setEnabled(false);
                server.shutdown();
                server = null;
                console.append("Console: Server has been stopped.\n");
        }Edited by: mcox05 on May 21, 2009 10:05 AM
    Edited by: mcox05 on May 21, 2009 10:17 AM
    Edited by: mcox05 on May 21, 2009 10:58 AM
    Edited by: mcox05 on May 21, 2009 11:01 AM
    Edited by: mcox05 on May 21, 2009 11:03 AM
    Edited by: mcox05 on May 21, 2009 11:03 AM

  • Help with Client/Server - basic error

    I get the following error message when I try to run the following code - why ?????? Is it something to do with it being run on a networked computer or what ??!?!
    import java.net.*;
    import java.io.*;
    import java.util.*;
    class ClientSimon {
    public static void main (String args[]) throws Exception {
    InetAddress addr = InetAddress.getByName(null);
    System.out.println(addr);
    try {
    Socket s = new Socket("127.1.1.0", 4444);
    } catch (UnknownHostException e) {
    System.err.println("Don't know about host!");
    System.exit(1);
    //////////ERROR MESSAGE FOLLOWS////////////////
    localhost/127.0.0.1
    java.net.ConnectException: Connection refused: no further information
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
    at java.net.Socket.<init>(Socket.java:273)
    at java.net.Socket.<init>(Socket.java:100)
    at ClientSimon.main(ClientSimon.java:13)

    hello earnshaw1,
    did you run your ServerSocket using port 4444?
    if you indicate a different port then it would definitely yield to the same error:
    -->localhost/127.0.0.1
    java.net.ConnectException: Connection refused: no further information
    try changing the port of your ServerSocket to 4444 and run it first before running ClientSimon..
    hope it helps!
    enjoi!

  • I need help with Mavericks Server: an error occurred while configuring your server.  I

    I need help with Mavricks Server, I get the following: an error occurred while configuring your server.  I have deleted the Server.app several times along with the associated com.apple and Server folder.  Any more help would be appreciated.

    There are usually some log files around, related to the installation.  See if Console.app (Applications > Utilities) shows anything relevant to the error, when you've done a fresh install of Server.app and tried the configuration.

  • Help with installing a CHAT CLIENT/SERVER

    i cant seem to get my chatclient or chatserver to successfully connect to my server. even if i do a local host 127.0.0.1 thing it STILL says that it cannot connect.
    the server is a stand alone.
    is there a general place to install the compiled files?
    im SO frustrated right now.
    im writing a card game. it is done but now i need to implement the networking. so im starting with a simple chat server and i cant even get THAT to work.
    HELP.....

    I'm actually working on a card game (client/server if I can) as well, when I spotted this message. Card games work for me because they're simple, they're relatively fun and easy to figure out, and they aren't real-time or heavy on animation/sprites/hardware acceleration.
    http://vpoker.sourceforge.net/ is a java based card game that has some excellent examples of how to conceptualize a 'card' object and a 'deck' of cards.
    good luck, can try emailing me if you want to toss around ideas about our respective card games.

  • Need help with a java chat software!!! Anyone pls give ideas

    I need to implement a chat protocol with sockets for my course!!
    As of now i have only got to the simple client server application with sockets and have a user interface with panels.
    How could I proceed...
    How should i use login names and passwords??
    Should i use if else loops to specify :
    various headers like
    login
    pass
    send
    exit
    if you could point out som esite that will be helpful or even a book it would be of great help!!

    Don't use if/else loops, they have this nasty habit of not existing.
    My quarter-pence:
    For passwords, use a map which maps name/hashed password. That way, you'll never actually store the password.

  • Help with OSX server mail setup

    Please if anyone can tell me what I am doing wrong, I would be very grateful.  I have a company with an externaly hosted website and an an internally hosted email (OSX server).  I have everything kind of working, but some things don't seem quite right.  I'll explain below:
    I have a purchased domain: mycompany.com hosted by godaddy.
    I am using Godaddy name servers: ns65.domaincontrol.com and ns66.domaincontrol.com
    The external godaddy DNS has an a name entry for my mail server: mail pointing to 123.123.123.123 (which is my companies external static IP address).
    There is also a null (@) a name record for my website hosting service (squarespace) pointing to 456.456.456.456
    There is a cName record www pointing to the squarespace domain "www.squarespace6.com"  (know this is unusual, but it is how squarespace asks this to be set up and does not work otherwise)
    There is an MX record with priority 10 and host name @ pointing to mail.mycompany.com
    I have a airport extreme router with the appropriate ports forwarded to the OSX server.
    The DNS servers on the router are pointed to the internal IP address of the OSX server
    I did not change the domain name on the router (mistake?) it is currently san.rr.com
    On the OSX server I have set up host name to be mycompany.comDNS is set up with primary zone being mycompany.com
    Primary Zone entries include
    nameserver = mycompany.com
    machine record host name is mycompany.com and the IP address is the internal IP address of the OSX server
    another machine record with host name "mail" and IP address is the internal IP address of the OSX server.
    Finally, there is a mail exchanger record with mail server "mail.mycompany.com" and priority 10
    There are 2 entries autocreated in the Reverse zone
    Mail is setup and running on the OSX server providing mail for "mail.mycompany.com"
    Users are setup with email address: [email protected] (note: without the mail subdomain - I think this is OK?)
    I am using self signed certificate.
    In my clients (windows Thunderbird, Mac Mail, iOS mail), the settings are for the incoming mail server host name to be "mail.mycompany.com" and the outgoing also to be "mail.mycompany.com"
    I woud have expected this to be imap.mycompany.com and smtp.mycompany.com respectively, but it doesn't work when I input these values and works with the former.  Have I set this up wrong??  imap seems to require SSL on port 993 and SMTP seems to require TLS on port 587.Outlook on PC gives me an error that after googling appears to be a problem with not recognizing a fuly qualified hostname form the SMTP client.  I see the fix, but wanted to know if that meant that my server didn't have a fully qualified host name and whether I should change that rather than just remove that restriction???
    The final problem is that my outgoing emails seem to be getting caught up in other people's spam filters too frequently.  What is the main reason for this?  Is it because I have set something up wrong and it brings up flags or is it simply because I am not a huge hosting company, or somethign else althogether?
    If you've gotten this far, big thanks!  If you can help me, even more thanks!

    Well, actually they are both getting caught up in spam filters and bounced back.  I actually realized that part of the problem is that I have a dynamic IP address, but it doesn't change.  Regardless, on the bounce back it looks like hotmail and other domains are rejecting email from my IP and recognize it as dynamic.  This was a test server that i would by physically taking to my business where there is a static business IP address (Cox).
    Sorry for the very long original message, but it seems that most people don't post enough information for the problem to be solved in their original posts and I was hoping to provide as much detail as possible.
    The other is the question of "are things set up right?"  It seems strange to me that both my outgoing and incoming servers are "mail.mycompany.com" and not imap.mycompany.com and smtp.mycompany.com and I wonder if this is going to cause me to have problems?
    Is it a problem that my email addresses are [email protected] and not [email protected]?
    Was I supposed to change the domain name on the router?
    Also is it going to be a problem that I am using a self signed certificate?

  • Help with a server program

    Hello,
    I don't know much about threading, but I've got this server program (code follows). And where it does this... :
                        // Create a new thread for the connection
                        HandleAClient thread = new HandleAClient(connectToClient);
                        cn = clientNo;
                        // Start the new thread
                        thread.start();I need it to create another instance of the client program that accessing it with the same thread(I think, as i said I don't know much about threads). That way when a remote user accesses the client program, the server will automatically open another client program on the machine the server is running on. Then while their both using the same thread, they'll be able to speak back and forth without anyone else getting their text.
    Does this make sense? Can anyone help?
    Here is the server code, I don't have it perfected yet to send the text, but the clients will regester with the server.
    // MultiThreadServer.java: The server can communicate with
    // multiple clients concurrently using the multiple threads
    import java.io.*;
    import java.net.*;
    import java.util.*;
    // MultiThreadServer should be able to
    //    handle text from multiple users at once
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MultiThreadServer extends JFrame {
         // Text area for displaying contents
         private JTextArea jta = new JTextArea();
         public static void main(String[] args) {
              new MultiThreadServer();
         public int cn = 0;
         public MultiThreadServer() {
              // Place text area on the frame
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(new JScrollPane(jta), BorderLayout.CENTER);
              setTitle("MultiThreadServer");
              setSize(500, 300);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true); // It is necessary to show the frame here!
              try {
                   // Create a server socket
                   ServerSocket serverSocket = new ServerSocket(8000);
                   jta.append("MultiThreadServer started at " + new Date() + '\n');
                   // Number a client
                   int clientNo = 1;
                   while (true) {
                        // Listen for a new connection request
                        Socket connectToClient = serverSocket.accept();
                        // Display the client number
                        jta.append("Starting thread for client " + clientNo +
                             " at " + new Date() + '\n');
                        // Find the client's host name, and IP address
                        InetAddress clientInetAddress =
                             connectToClient.getInetAddress();
                        jta.append("Client " + clientNo + "'s host name is "
                             + clientInetAddress.getHostName() + "\n");
                        jta.append("Client " + clientNo + "'s IP Address is "
                             + clientInetAddress.getHostAddress() + "\n");
                        // Create a new thread for the connection
                        HandleAClient thread = new HandleAClient(connectToClient);
                        cn = clientNo;
                        // Start the new thread
                        thread.start();
                        // Increment clientNo
                        clientNo++;
              catch(IOException ex) {
                   System.err.println(ex);
         // Inner class
         // Define the thread class for handling new connection
         class HandleAClient extends Thread {
              private Socket connectToClient; // A connected socket
              // Construct a thread
              public HandleAClient(Socket socket) {
                   connectToClient = socket;
              // Run a thread
              public void run() {
                   try {
                        // Create data input and output streams
                        DataInputStream isFromClient = new DataInputStream(
                             connectToClient.getInputStream());
                        DataOutputStream osToClient = new DataOutputStream(
                             connectToClient.getOutputStream());
                        osToClient.writeDouble(cn);
                        // Continuously serve the client
                        while (true) {
                             // Receive radius from the client
                             double radius = isFromClient.readDouble();
                             // Compute area
                             double area = radius*radius*Math.PI;
                             // Send area back to the client
                             osToClient.writeDouble(area);
                             jta.append("radius received from client: " +
                                  radius + '\n');
                             jta.append("Area found: " + area + '\n');
                   catch(IOException e) {
                        System.err.println(e);
    }And here is the Client Program code, note that the sending of text does not yet work here either.
    // Client.java: The client sends the input to the server and receives
    //           result back from the server
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    public class Client extends JFrame implements ActionListener {
         // Text field for receiving radius
         private JTextField jtf = new JTextField(40);
         // Text area to display contents
         private JTextArea jta = new JTextArea();
         // IO streams
         DataOutputStream osToServer;
         DataInputStream isFromServer;
         public static void main(String[] args) {
              new Client();
         public Client() {
              // Ask the user for a name
              String s = JOptionPane.showInputDialog
                   (null, "Please Enter Your Name:", "ZedX Web Messenger", JOptionPane.QUESTION_MESSAGE);
              // Panel p to hold the label and text field
              JPanel p = new JPanel();
              p.setLayout(new BorderLayout());
              p.add(new JLabel("Enter Text"), BorderLayout.WEST);
              p.add(jtf, BorderLayout.CENTER);
              p.add(new JButton("Go"), BorderLayout.EAST);
              jtf.setHorizontalAlignment(JTextField.LEFT);
    //          jta.editable(false);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(p, BorderLayout.NORTH);
              getContentPane().add(new JScrollPane(jta), BorderLayout.CENTER);
              jtf.addActionListener(this); // Register listener
              String user = "Client";
              setTitle(user);
              setSize(500,500);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true); // It is necessary to show the frame here!
              try {
                   // Create a socket to connect to the server
                   Socket connectToServer = new Socket("10.0.5.39", 8000);
                   // Create an input stream to receive data from the server
                   isFromServer = new DataInputStream(
                        connectToServer.getInputStream());
                   // Create an output stream to send data to the server
                   osToServer = new DataOutputStream(connectToServer.getOutputStream());
                   // Send client Name to server
                   // Get client number and name from server
                   double cn = isFromServer.readDouble();
                   user = user + " " + cn + ":  " + s;
                   setTitle(user);
              catch (IOException ex) {
                   jta.append(ex.toString() + '\n' + "Administrator must be offline, try again later.");
         public void actionPerformed(ActionEvent e) {
              String actionCommand = e.getActionCommand();
              if (e.getSource() instanceof JTextField) {
                   try {
                        // Get the text from the text field
                        String radius = jtf.getText();
                        // Send the text to the server
                        osToServer.println(radius);
                        osToServer.flush();
                        // Get text from the server
                        double area = isFromServer.readDouble();
                        // Display to the text area
                        jta.append("You Sent: " + radius + "\n");
                        jta.append("Server" + area + '\n');
                   catch (IOException ex) {
                        System.err.println(ex);
    }

    bump

  • Need Help for client - server - client question [Sockets]

    Hi
    I have read the http://java.sun.com/docs/books/tutorial/networking/sockets/index.html tutorial and made this Knock Knock Application.
    But now, I want that one client can view all the other clients which are connected to the server, and interract with a selected cleint over the server (client - server - client).
    But I have no idea how to build such a registration concept?
    A concrete hint (or link) how to realise this would be very helpful. I searched all the internet for examples, but I dont found a simple example.
    Thanks in advance
    greeds

    wSam,
    It appears that Sun considers RMI to be simpler, although less efficient than the alternative:
    http://java.sun.com/developer/technicalArticles/ALT/sockets/
    This article also talks about object serialization, which I am a fan of. Suppose that you want to send a data structure containing lots of information (like all connected users). You can actually pass an object (rather than text) across the network using ObjectOutputStream and receive it on the other end with ObjectInputStream. You might create your own Command class for passing objects between the client and server instead of using RMI. The Command class might hold flags that indicate which method should take place on the remote machine (i.e. send chess move command).

  • Need help clarifying client/server TNS communication

    Im trying to get a clearer understanding of service/listener registration in the Oracle client/server architechure. Feel free to point out errors in my understanding.
    When an Oracle client connects to the server, it forms its connect descriptor based on the clients tnsnames.ora file. The client then checks the specified port on the host in the connect descriptor for a listener that is registered with the service defined in the
    (CONNECT_DATA =
    (SERVICE_NAME = TESTSERVICE)
    portion of the client's tnsnames file. Correct?
    Does the listener gets its list of SIDs its registered with from the SID_LIST section of the listener.ora file or the tnsnames file?
    If the listener gets its list of SIDs to register with from the tnsnames file, is that the tnsnames file on the server?
    If so, then what is the SID_LIST used for in the listener.ora file?
    Im trying to connect the dots and any help would be much appreciated.
    Thanks,

    Reading below documents would help you understand how client/server TNS communication works:-
    Listener Architecture
    http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/architecture.htm#sthref445
    Configuring Naming Methods
    http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/naming.htm
    Configuring and Administering the Listener
    http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/listenercfg.htm

Maybe you are looking for

  • Void and Reissue Payments

    We have a scenario where a factor(associated with more than a hundred suppliers) has a payment returned from bank. For the above scenario there could potentially be hundreds of checks involved if a factor's payment is returned as payables processs a

  • TV@nywhere Plus FM problem

    I guys, I have no problem using the TV tuner, image is ok, sound is ok, record is ok... but if I choose FM, I will get the interface but cant ear anything? When you read the spec for the card, beside FM tuner you will see a (option)... How do I know

  • Stop/Start Web Application - Not redeploy

              (WLS 6.1 SP3)           When I deploy an application using the console the JSPs are all seen as up-to-date           and it does not need to recompile them.           If I try to deploy it using the command line "weblogic.deploy update" the

  • In my library disc 2 comes before disc 1

    i imported a 2 disc cd to my itunes library but disc 2 is positioned before disc 1 in the sequence order of albums. How can I correct this?

  • MONTH END CLOSING ACTIVITY

    Dear all pl, explain few questions 1) What r the month end closing activities done in SAP PP? 2) How do u capture product cost? 3) What is Teco, closing a prod. orderand order settlement? thanks Raj