Connection between server and client using thread

hi
i am new to java..i hav done a program to connect a server and client...but i hav not used threads in it..
so please tel me how to use threads and connect server and client..i tried it out not getin...i am havin thread exception...my program is as shown below
SERVER PRG:
import java.io.*;
import java.net.*;
public class Server{
String clientsen;
String serversen;
public void go(){
try{
     ServerSocket serverSock=new ServerSocket(6789);
     while(true) {
     Socket sock=serverSock.accept();
     BufferedReader inFromClient=new BufferedReader(new InputStreamReader(sock.getInputStream()));
     BufferedReader inFromuser=new BufferedReader(new InputStreamReader(System.in));
     DataOutputStream outToClient=new DataOutputStream(sock.getOutputStream());
     clientsen=inFromClient.readLine();
     System.out.println("From Client: "+clientsen);
     System.out.println("Reply mess to Client");
     serversen=inFromuser.readLine();
     outToClient.writeBytes(serversen+'\n');
} catch(IOException ex) {
     ex.printStackTrace();
public static void main(String[] args) {
     Server s = new Server();
     s.go();
     CLIENT PRG
import java.lang.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.lang.Thread;
import java.applet.Applet;
class Client1
public static void main(String argv[]) throws Exception
          String Sen;
          String modsen;
          BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket=new Socket("192.168.1.2",6789);
          DataOutputStream outToServer=new DataOutputStream(clientSocket.getOutputStream());
          BufferedReader inFromServer=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          System.out.println("Enter the mess to be sent to server");
          Sen=inFromUser.readLine();
          outToServer.writeBytes(Sen + '\n');
          modsen=inFromServer.readLine();
          System.out.println("FROM SERVER: " +modsen);
          clientSocket.close();
please send me the solution code for my problem...

sorry for inconvenience...
SERVER PROGRAM
  *import java.io.*;*
*import java.net.*;*
*public class MyRunnable implements Runnable*
   *public void run() {*
   *go();*
*public void go(){*
*try {*
    *String serversen;*
   *ServerSocket  welcomeSocket=new ServerSocket(6789);*
   *while(true)*
*Socket connectionSocket=welcomeSocket.accept();*
*//BufferedReader inFromClient=new BufferedReader(new //InputStreamReader(connectionSocket.getInputStream()));*
*System.out.println("enter the mess to be sent to client");*
*BufferedReader inFromuser=new BufferedReader(new InputStreamReader(System.in));*
*DataOutputStream outToClient=new DataOutputStream(connectionSocket.getOutputStream());*
*//clientsen=inFromClient.readLine();*
*//System.out.println("From Client: "+clientsen);*
*//System.out.println("Reply mess to Client");*
*serversen=inFromuser.readLine();*
*outToClient.writeBytes(serversen+'\n');*
*} catch(IOException ex) {*
*        ex.printStackTrace();*
*class Server1{*
*public static void main(String argv[]) throws Exception*
     *Runnable threadJob=new MyRunnable();*
*Thread myThread=new Thread(threadJob);*
*myThread.start();*
*}*CLIENT PROGRAM
import java.io.*;
import java.net.*;
class Client2
public static void main(String argv[]) throws Exception
          //String Sen;
          String modsen;
          //BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket=new Socket("192.168.1.2",6789);
          //DataOutputStream outToServer=new DataOutputStream(clientSocket.getOutputStream());
          BufferedReader inFromServer=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          //System.out.println("Enter the mess to be sent to server");
          //Sen=inFromUser.readLine();
     //     outToServer.writeBytes(Sen + '\n');
          modsen=inFromServer.readLine();
          System.out.println("FROM SERVER: " +modsen);
          clientSocket.close();
this is the code which i hav used using thread but i am gwetin error..ts is the error
Exception in thread "main" java.lang.NoSuchMethodError : Main

Similar Messages

  • Speed between server and client when using FML

    I using FML between server and client, the server access oracle using only 5 ms, but when tranfer back to client, it about 100ms long. I tuned my hp-ux 11 kernel and tuxedo config file, but useless, Why?

    Hi Tumecan,
    Your expected information available here, check.
    Frontend Network Load - Network Integration Guide (BC-NET) - SAP Library
    few related SAP Notes:
    164102 - Network load between application server and front end
    500235 - Network Diagnosis with NIPING
    62418 - Network Load of SAPGUI Frontend Communication
    679918 - The front-end network time
    578118 - Long response times on the SAP GUI
    161053 - Using SAP GUI in WAN
    Regards,
    V Srinivasan

  • Data streaming between server and client does not complete

    Using an ad-hoc app, data streaming between server
    and client does not complete as it supposed to be.
    The process runs well in solaris 5.8, however under 5.9
    we have found the characters stream buffer length limitation
    is around 900 to 950 characters (by default we are using 3072
    characters).
    Example:
    - We are transfering HTML file, which will be displayed
    in the App client, with buffer=3072, the HTML only displayed / transfered
    as xxxxxxxx characters, but with buffer=900 the HTML is displayed properly,
    in this case, the only problem that we have is the file transfer will
    eventually longer than usual.
    - There is another case, where we have to transfer information (data) as stream
    to the client. A long data stream will not appear at all in the client.
    Any ideas why the change between 5.8 and 5.9 woudl cause problems?
    The current app-driver that we are using is compiled using Solaris 5.6,
    if possible we would like to have use of a later version, which is compiled using Solaris 5.9, do you think this will probably solve our problem?
    Thanks
    Paul

    Does this have anything to do with Java RMI? or with Java come to think of it?

  • Serialize the object between Server and Client?

    Hello friends,
    What is the important to Serialize the object between server and client?
    Thanks
    tamilvanan

    in which context ??
    Anyways,checkout the below link and try to understand how do we convert Serializable Object's State to in Stream and send it over network.
    http://java.sun.com/j2se/1.4.2/docs/guide/serialization/examples/index.html
    Hope that might help :)
    REGARDS,
    RaHuL

  • Bandwidth between server and client

    HI
    What is the minimum bandwidth can be allocated between server and client?

    Hi,
    Your question has no standard answer. The minimum bandwidth is variable to each specific system. It depends on many other factors too.
    Thanks,
    Gordon

  • Time sync between server and client

    Hi guys,
    I have written a chess server and client. My next step is to implement a clock which will be used in timed games, however, I am not sure of the best solution. I can't think of a reliable method to keep the client's time in sync with the servers because the event latency varies between individual events and clients.
    My first idea was to send a 'tick' event every second but I dont think this the best solution. I have seen many applet based clients which have timers, such as Yahoo chess.
    I know this question is a little vague, I can give more detail if needed.
    Thanks,
    Alex

    To prevent client-side cheating, the server should keep the
    "official" clock. Every so often (perhaps when a move gets made?),
    notify both clients of the official time. Clients count seconds from
    that official time.
    This is a suboptimal solution because it leaves clients vulnerable
    to network lag. I can't think of any other solution that doesn't give
    clients some responsibility for tracking time, though, and that's a
    big security hole.
    If you're willing to open that hole, have each client report back to
    the server the elapsed local time from when they recieved the
    last move to when they made their move. Then update the other
    client's clock accordingly.

  • Difference between Server and Client Installation of ODI

    Hi All,
    i am new to ODI, recently i try to install ODI it has three Option 1.Complete 2. Client 3. Server
    i installed Server after installation it contains only Agent. and i tried Client option end of the installation i saw all the ODI components including Agent. i am bit confusion about when do i need to use ODI Server and when do i need to use ODI Client and what is the purpose of both
    Thanks
    Knidhi
    Edited by: knidhi on Oct 6, 2009 2:38 PM
    Edited by: knidhi on Oct 6, 2009 2:38 PM

    Hi,
    Trying to help :-
    What roll ODI Server play in the entire ODI ArchiTechture?
    ODI Server will act as a cenratilsed system for all your ODI clients
    You can call this ODI server as an execution server for all your ODI clients .
    When this is needed ?
    (some real time examples to explain the need)
    If there is team need to work on a cenratlised application ...
    say MachineDev1 (developer1) , MachineDev2 (developer2) .. and MachnAnlayst1 (An1), MachnAnlayst2 (An2) need to work on an single application
    The developer1 will create projects based upon his machine ,
    The developer2 will create projects based upon his machine ,
    and the analysts/operators will try to execute the application from their machines with their machine agents.
    the application will reffer the paths for temperory/supporting files/folders on the agent machines which they are running ...
    this will be a difficult task, if you dont have a similar folder sturcture in all of your machines ..
    In order to avoid this conflict you need a centralised system for running your jobs from different machines
    say SVR (from your example). put all the supporting files/folders in this system while developing projects each develpoer need to consider this server as an execution server.
    so if any execution comes from any clients with this agent, it will reffer to the machine SVR folders and you can have a centralaised enviorment to work for different machines.
    Regards,
    Rathish

  • Transfer files between server and clients

    Hi all
    i use oracle forms 11g r2 webutil
    i have some questions :
    1- How i can choose picture from client side and save it on server ( in folder ) ?
    2- How i can print the picture from client side?
    Thanks

    Hello,
    For transfering files, configure the Webutil library, then use its AS_To_Client() and Client_To_AS() methods.
    Francois

  • Passing parameters between server and client side

    Dear All
    I writing a server-side web service and using wsdl to expose its methods for a 'client' to use.
    However, i need to make sre the clients creates a soap header? How can i tell the client it must create a soap header?
    Also can someone tel me how i pass a value from the server-side to the client-side and also get a vlue from the client soap message
    Many thanks

    In your wsdl you would have the header as part of the input for example, see the operation below:
    <wsdl:operation name="foo">
    <soap:operation soapAction="http://www.foobar.com/foo" style="document"/>
      <wsdl:input>
       <soap:body use="literal"/>
       <soap:header message="tns:FooSoapHeader" part="MySoapHeader" use="literal"/>
      </wsdl:input>
      <wsdl:output>
       <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>

  • Need help sharing internet connection between pc and mac using airport

    Hello
    I have a PC with an internal modem that connects to the internet via 3g+. it's got wi-fi as my macbook.
    i want to share the internet connection of the pc via wifi (using what is called an "ad hoc" connection ( a pc to pc network)) so that the mac can connect to the pc (via wifi) and use its internet connection.
    i've already tried a bunch of things but they don't work, can someone help me or tell me where i can find a GOOD guide to do this? (i've already looked around but i haven't found anything that works)
    thanks

    Hi. I'm not sure if this helps, but I just found a nice way to do it the other ways around (share the internet from your mac with your pc).
    See: http://echeng.com/journal/2009/07/06/encrypted-internet-sharing-between-mac-os-a nd-windows-xp/
    Specifically, step 4 and 6 are crucial!:
    1. In Mac OS X, enable Internet Sharing to computers using Airport
    2. In AirPort Options, select 128-bit WEP encryption and enter a 13-character password
    3. In Windows, add a new wireless network
    4. Enter the SSID and select WEP encryption with Shared Network Authentication (not Open)
    5. Uncheck “The key is provided automatically” and enter the 13-character password
    6. In the Authentication tab, be sure that “Enable IEEE 802.1x authentication” is unchecked
    The main idea is that MAC-WEP and PC-WEP are not quite the same, so this tweak makes them line up. Perhaps you can do it the other way around from PC to MAC by sort of reversing the idea?
    Hope that helps you!

  • Xsan between server and client??

    Sorry, if my question should be stupid:
    I am installing now a FC Raid to a Xserve. The raid is neither Promise nor Xraid. Could I connect a specific workstation (MacPro) with the Xserve via xsan (and FC) to get higher transmission speed for that workstation?
    I understand, that normally you connect several servers with one or serveral San-Storage.
    Thanks in advance!

    Hi,
    Well, that depends on the FC interface on the RAID..
    But it should be faster, as the data path is dedicated in FC.
    You do, though, need a huge setup for that small installation, so it has to be worth it.
    FC switch, dedicated Ethernet Metadata network (could be VLAN'ed on an existing switch) and SAN software.
    But, the speed is higher, compared to AFP if you have enough RAID controllers with bandwidth.
    Apple's XRaid has 80MB/sec pr. controller at 2GB FC.
    Promise uses 4x4GB FC interfaces / chassis, so those should be higher. Yours my offer something different.
    Hope it helps...

  • Difference between SERVER and CLIENT side conflicts?

    Some sync conflicts (ApplyChangeFailed event) are generated on the server side (WCF service in my case) and some are generated on the client side ... what triggers the conflict
    to be generated on one side or the other?

    the ApplyChangeFailed is fired by the provider that's applying the change.
    When you upload, it fires on the destination/remote provider.
    when you download, it's your local provider applying the change.

  • XL Reporter Problem:  Version Mismatch between server and client

    When I start SAP Business One, I get the following message:
    "The new version of Add-on is installed.  Upgrade the Add-on in the current Common DB."
    The version of the XL Reporter add on shown in the Add-On Administration is 881316, but the version of the add-on in the Add-On Manager screen is 881 316 00 08 (equates the verions of SBO installed).
    Does anyone have any advice on how to correct?   Do I need to reinstall SAP Business One on the server?
    Regards
    Jeffrey Patch

    Hi,
    Check this link :
    https://websmp202.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700000827312009E
    Check Application Error/Limitation > Reason 6 in the link.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • How to set up connection between S and C

    I want to realize a chat between server and client.
    on both side ,there is a textArea to get the information to send to the other.
    I know the socket is must be used,but how to set up the data source(from textarea or textfield),and how to store the data?
    can some one tell me how to do this?
    thanq!

    So what are you saying you dont know how to use the textarea and textfield?Cause it is ez to convert that code that dunedinhigh gave you from console to a gui like what you want I think.So here is a link that shows you how to use text component.You learn this then you can put 2 and 2 together.Also check out the java tut page.
    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html
    good luck

  • Windows Media Player no sound while playing a avi file in server and client connection using TCP/IP connection

    Hello there
    I have a problem with my windows media player while using server and client connection by using TCP/IP connection. So when I play a video using Windows Media Player in LabVIew there isn't any sound come out but when I'm playing a video by a Windows Media Player only the sound will come out. Can you help me solve this problem?
    I also upload the vi as the reference.
    The username for the client is ihsanhaikalz and the password is ganteng
    Thanks
    Attachments:
    Client Remote.vi ‏746 KB
    Server Remote.vi ‏1433 KB

    Hi ican,
    I was looking at your VI's but I cannot seem to pinpoint exactly where you are using Windows Media Player.  In order to more quickly assist you, could you please recreate this issue more concisely in a smaller set of VIs.  Also, were you able to get sound when you did not use the TCP/IP connection and simply played the files in LabVIEW?
    I noticed in a few places that you were using the Play Sound File.VI from the Graphics and Sounds palette.  Is that what you are refering to?  I noticed there that the file path that you have designated for the song is simply the song title.  Instead, this should be a path to where the song is located on your computer.
    Also, if you are planning on using Windows Media Player, have you considered using the ActiveX commands for Windows Media Player?  Here are a few examples if you are unfamiliar with this functionality.
    Example 1 and Example 2.
    I hope this helps!
    Kim W.
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Adobe digital edition 2.0 stopped working.

    Last night i read a book on ADE 2.0 and in the morning when i tried opening it , ADE crashed and it says ADE not working. I tried repairing it and re installing it but still the problem persists. I created a new user account on my win 8.1 , its worki

  • Using a function to create a report

    Hi, I have a report created with a select statement, I would like to create a function which will return the result of the select statement and use this function to create the report ? Does anybody know how I can do it ? I mean how to create a functi

  • ANSI to traditional (+) join syntax

    Hi All, Can anyone pl help me to understand how the diff tables in this tables are joined ( even 1 join would help) as I am not able to differentiate where the first join ended and whether the result is attched to the previous one or what all :( I am

  • Missing windows partition after upgrading to OS X Yosemite

    Can you post the text version of output of the following commands from Terminal? diskutil list diskutil cs list sudo gpt -vv -r show /dev/disk0 sudo fdisk /dev/disk0 Sudo commands require your password, which is not echoed back you. It may also warn

  • Some items were not copied because software is too old

    I've updated to 7.0.2 and finally decided to brave the waters and sync my iPod--I've been too chicken to sync it at all since 7.0 came out and all of the issues began appearing. Of course, when I plugged in the iPod, it asked if I wanted to update &