Socket help?

Alright I have to modify these two programs for a school project. However I can't even get the ones she gave us up and running. So it's obvious that I can't modify them until I get the ones she gave us up and running. Any help that you could give me would be awesome.
The error I get is java.net.ConnectException: Connection refused: connect
Exception in thread "main" java.lang.NullPointerException
     at DateClient.main(DateClient.java:29)
The programs are, please don't ask me what they do that's why I need the first one up and running. All I know is that we are supposed to send information through a socket. Thanks for the help.
  import java.net.*;
   import java.io.*;
    public class DateClient
       public static void main(String[] args) throws IOException {
         InputStream in = null;
         BufferedReader bin = null;
         Socket sock = null;
         try {
            sock = new Socket("127.0.0.1",6013);
            in = sock.getInputStream();
            bin = new BufferedReader(new InputStreamReader(in));
            String line;
            while( (line = bin.readLine()) != null)
               System.out.println(line);
             catch (IOException ioe) {
               System.err.println(ioe);
         finally {
            sock.close();
   }This is the second one:
import java.net.*;
import java.io.*;
public class DateServer
     public static void main(String[] args) throws IOException {
          Socket client = null;
          ServerSocket sock = null;
          try {
               sock = new ServerSocket(6013);
               // now listen for connections
               while (true) {
                    client = sock.accept();
                    System.out.println("server = " + sock);
                    System.out.println("client = " + client);
                    // we have a connection
                    PrintWriter pout = new PrintWriter(client.getOutputStream(), true);
                    // write the Date to the socket
                    pout.println(new java.util.Date().toString());
                    pout.close();
                    client.close();
          catch (IOException ioe) {
                    System.err.println(ioe);
          finally {
               if (sock != null)
                    sock.close();
               if (client != null)
                    client.close();
     }

'javac' is not recognized as an internal or external command,
operable program or batch file.
This is what I get when I attempt to compile it in the command prompt.
hi :-)
kidz now are having problems with DOS. they dont even know what DOS means. same problem was asked. i think it was yesterday :-( huhu :-(
by the way try this solutions
1. add your java folder to your Environment File PATH
or
2. directly access the javac from its folder
ex. C:\Program Files\Java\jdk1.5.0_08\bin\javac filename.javaalternatively you can put that line of code on a batch file,
so you will no longger type that long directory structure.
regards,

Similar Messages

  • Server Socket Help!

    Hello!
    I have a problem regarding server socket, i wrote a simple server socket program which would accept a socket then write through the DataOutputStream, using writeByte and read through the DataInputStream using readUnsignedByte.
    My server socket is a java program, and the client was created using other language (which i do not know what language but it is already existing..).
    My concern is that when I try to listen (in the server side), i would accept the socket, and the connection would now be established. BUT, whenever i would close my streams (input and output stream), the client socket I accepted and the ACTUAL server socket, the client is still connected. That's why whenever i would open my Server Socket, i would no longer receive any socket.. why is it like that..?
    Can anyone help me..? Please do so.. I would appreciate your immediate reply..
    Thanks a lot!
    Ron

    HI,
    What you need in the client app is for it to listen for a CLOSE message like this (java code but the logic is there)
    String fromServer ;
    while(( fromServer = in.readLine()) != null )
    System.out.println( "Server: " + fromServer ) ;
    if( fromServer.equals("Closing down")) //checks all the time for the CLOSE signal !
    break ;
    // other stuff
    out.close() ; // close the client end of the socket on the signal !
    in.close() ;
    You say the client app is already written. Well look in the specs and see what the CLOSE signal is.
    There MUST be one or the client app doesn't work.
    Hope that helps,

  • Multithread program with socket, help me

    Hi all, I have had some troubles with my multithread program, that is when I make 4 threads to send messages to 4 accepted ports: 2001, 2002, 2003 and 2004, it leads to the error:
    "Java.net.SocketException: Software caused connection abort: recv fail"
    I cannot understand why this exception is inconsistent. Please help me figure out
    solution for this problem. Thank you.
    Here is my code
    public synchronized void sendREQMessage(Message obj)
         for(int i=2001;i<=2004;i++)
              try
                             obj.setPortDest(i);
                             myThread thread=new myThread(obj,i);
                   catch (Exception e)
                        System.out.println(e);
    public myThread(Message obj,int i)
              message=obj;
              port=i;
              start();
         public void run()
              try
                   message.setPortDest(port);
                   connection = new Socket("127.0.0.1",port);
                   out = new ObjectOutputStream(
         connection.getOutputStream());               
                   out.writeObject(message);
                   out.flush();
                   //connection.close();
              catch(Exception e)
                   System.out.println(e);
         }

    I'm sorry, I cannot understand what you mean.
    Sometimes, the message can be sent well among 4 ports. Sometimes, it leads to the error:
    "Java.net.SocketException: Software caused connection abort: recv fail"
    And I don't know why.
    Thank for your help

  • IPlate/Master Socket, Help Needed!

    (Before i start this is my first post so  sorry if i mess something up )
    Hi,   
    I want to install a BT Iplate but i have a Master socket that is not supported. (Pic below)
    Is there any chance i can change my master socket to the one below so i can install an iplate?

    Hi Eaglealex7,
    The newer Openreach BTNTE5 master socket already filters interference from extension sockets. Pre-filtered ADSL/VDSL master sockets also already filters interference from extension sockets.
    if you have a look at this link here it will tell you what Master sockets work with the iplate / Accelerator : http://www.productsandservices.bt.com/consumerProd​ucts/displayTopic.do?topicId=25075
    The accelerator/iplate can sometimes cause more issues in some cases. Have a look at removing the BellWire/Ring wire from terminal 3 of your master socket and extension sockets which does the same thing as the accelerator/iplate but sometimes more effective. Link : bellwire removal
    Cheers
    jac_95 | BT.com Help Site | BT Service Status
    Someone Solved Your Question?
    Please let other members know by clicking on ’Mark as Accepted Solution’
    Try a Search
    See if someone in the community had the same problem and how they got it resolved.

  • TCL Socket Help

    I've been trying to write a script that would telnet to another device to run some commands. Unfortunately, whatever I do, it seems I'm never getting past the motd banner. When executed, the script does open the session, and I get the full banner, but then it stops until the other device times out. I never the "Username:" prompt. Wireshark tells me the prompt is delivered, so I don't know what I'm doing wrong.
    Help!
    proc waitfor {sock pattern {delay 500}} {
      while { 1 } {
        after $delay { return -code error "delay expired" }
        gets $sock line
        puts $line
        if { [string match [string tolower $pattern] [string tolower $line]] } {
          puts "match"
          return -code ok
    set host "yoink!"
    set username "yoink!"
    set password "yoink!"
    set hostname "yoink!"
    puts "Trying to connect to $host\n\n"
    set sock [socket $host 23]
    waitfor $sock "username:"
    puts $sock $username
    waitfor $sock "password:"
    puts $sock $password
    waitfor $sock "$hostname#"
    puts $sock "show clock"
    waitfor $sock "$hostname#"
    close $sock

    After some more tests, I found something odd.
    Here's an output while running the script.
    router#tclsh tftp://10.120.1.2/telnet3.tcl
    Loading telnet3.tcl from 10.120.1.2 (via GigabitEthernet0/0): !
    [OK - 811 bytes]
    Trying to connect to 10.180.39.1
    {^A{^C}^X}^_    <- Telnet negociation garbage
    MOTD Banner Here!
    Username:       <- There's a long delay (auth timeout) before this appears
                       And all following lines appear at once.  
    step 2          <- Some debug
    % Username:  timeout expired!
    error reading "sock0": broken pipe
        while executing
    "gets $sock line"
        (procedure "waitfor" line 4)
        invoked from within
    "waitfor $sock "password:""
        (file "tftp://10.120.1.2/telnet3.tcl" line 28)
    router#
    So I did a manual telnet, and it looks like this.
    router#telnet 10.180.39.1
    Trying 10.180.39.1 ... Open
    MOTD Banner Here!
    User Access Verification  <- This line doesn't appear in the script
    Username:
    So it seems this line is causing the script to bog down somehow.

  • I pad1 will only charge up via computer port.suddenly not from a wall socket. help .thanks

    my i pad1, suddenly not charge up from wall socket , just from my pc .any suggestions . thanks

    Sounds like the charging cable is OK but the charger itself may have failed. Do you have another you can try - or perhaps borrow one for testing purposes?

  • Java Sockets - help with using objects

    I am new to java sockets, and need to come up with a way to send a user defined instance of a class across a basic client/server application.
    I can not find out how to do this. I read the tutorials, but my class can not be serialized. How can I send/recieve this instance of a user defined class?

    right off the top of my head, doesn't serialver just spit out a UID for a given set of classes?
    To mark a class as Serializable, just implement the java.io.Serializable class - then you could use the readObject/writeObject methods of the ObjectInputStream/ObjectOutputStream classes.
    Good luck
    Lee

  • Unable to send .mp3 with sockets, help!

    I need to send my .mp3 files throw a server but it stays in stuck in out.write(lenght), any suggestions for another type of way to do this...
    Other files are sent fine, .pdf, .txt, .doc... i might be the size but how to solve it...
    try {
                Socket socket=null;                 
                socket = new Socket(GlobalValues.ipOut, GlobalValues.portOut);
                OutputStream out = socket.getOutputStream();     
                InputStream fis = new FileInputStream(f);
                int length=0;
                BufferedInputStream buf = new BufferedInputStream(fis);
                //byte[] buffer = new byte[9*9*1024];
                GlobalValues.creatTextArea("                 Uploading PLEASE WAIT...", 1, Color.red, 0); 
                while((length = buf.read()) != -1){
                    out.write(length);
                    out.flush();
                GlobalValues.creatTextArea("                  FINISHED upload", 1, Color.green, 0);             
                fis.close();
                out.close();
            catch(Exception e){
                e.printStackTrace();
            }

    OutputStream out = socket.getOutputStream();     OutputStream out = new BufferedOutputStream(socket.getOutputStream());
    int length=0;This is not a correct name for this variable. You are reading bytes from the input stream, not lengths. A better name would be 'data'.
    while((length = buf.read()) != -1){
    out.write(length);
    out.flush();Move this flush to after the loop.
    If you're blocking in the write() it means the reader is slow reading. Using the BufferedOutputStream may fix this.

  • Iphone 4 just turned itself off, won't turn on again - sleep/wake button hasn't worked for a while - tried charging (even though it was 50% charged when it shut down) and that makes no difference....tried usb to computer and directo to wall socket. help?

    phone 4 just turned itself off, won't turn on again - sleep/wake button hasn't worked for a while - tried charging (even though it was 50% charged when it shut down) and that makes no difference....either via usb to computer and direct to wall socket. Any suggestions...other than heading off to the genius bar tomorrow?

    Well, the sleep/wake button is also the power button. If you cannot use it to turn on, then you cannot use it to perform a reset by holding it and the home button together until you see the Apple logo.Those are the only two ways to turn the device on. You can try letting the battery go completely dead and then trying to plug it in. After it has charged for 20-30 minutes, the device may come back on. But, without the sleep/wake button, there is no other way to turn the device on or off.

  • Need socket help

    Hello I am trying to send a byte array to an other computer but
    I get this message
    java.netConnectException: Connection refused:
    I read this about the error
    If the server is not responding on the port we?re looking for, we?ll get a ?java.netConnectException: Connection refused:..? message.
    but with a c program that works I receive data.
    This is my code
    msg1 is a byte array I want to send
    String server = "10.20.40.74";
    int port = 11220; //echo port
    //First conduct a TCP echo test
    try{
    //Get a socket, connected to the specified server
    // on the specified port.
    Socket socket = new Socket(server,port);
    //Get an input stream from the socket
    BufferedReader inputStream =
    new BufferedReader(new InputStreamReader(
    socket.getInputStream()));
    //Get an output stream to the socket. Note
    // that this stream will autoflush.
    PrintWriter outputStream =
    new PrintWriter(new OutputStreamWriter(
    socket.getOutputStream()),true);
    //Send line of text to the server
    outputStream.println(msg1);
    //Get echoed line back from server and display it
    System.out.println(inputStream.readLine());
    //Close the TCP socket
    socket.close();
    }//end try
    catch(UnknownHostException e){
    System.out.println(e);
    System.out.println(
    "Must be online to run properly.");
    }//end catch UnknownHostException
    catch(SocketException e){System.out.println(e);}
    catch(IOException e){System.out.println(e);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    If I do this (telnet) I get connection refused.
    But when I use the same address and portnumber with my c program I get an answer.
    The computer where I send the array to is listening at address 10.20.40.74 at port 11220, but wants an encrypted byte array, is it possible that the array isn't encrypted on the right way so it doesn't understand what it has to do with it and that's why the connection is refused??

  • BT master socket help please

    Hello everyone
    About 10 years ago when I still lived with my folks I decided to get broadband but as the pc was in my room it meant running a big long wire from the built in pc modem down to the phone socket in the hall way  
    So an engineer came round and made the socket in my room the master phone socket, now all these years later Ive moved out but now my mum and dad are having terrible troubles with their laptop struggling to pick up the router signal which has to be upstairs in my old room with the master socket and they have terrible broadband speeds. My question is could I myself swap around the master socket from my old room to a downstairs socket easy enough or would I need an engineer ?  Im guessing I could do it with the right instructions as Ive seen engineers do it very quickly and easily.
    Does anyone know of any detailed online instructions/video tutorials etc so I can do this please ? Ive looked but am struggling to find any.
    Thanks so much in advance
    Joe

    Sorry, one thing I'm not clear about from the original post. Is there still a working socket downstairs which has been used as an extension. If so you may be able to just relocate the hub. Provided the wire is in good condition you shouldn't get too much drop off.
    BT would need to see the socket to know if you've moved it, but if you have a problem at any time with your broadband you'll have some explaining to do and may be charged.

  • Athlon 64 2800+ 754 Socket HELP!

    so for the last couple weeks ive been trying to find a solution to overclocking my CPU.
    since i am using a K8MM-V (ms-7142) there are NO options for OC in my BIOS which is quite frustrating.
    any suggestions? SoftFSB and MSI CoreCenter both Dont support my mobo.

    Hello!
    This is a Value board and doesn't have many BIOS options. The manual doesn't say much either. Think you have to use some other software to "do" things.
    For overclocking questions I suggest you create a list of the important components of your system including the max amps of your PSU, and post in this forum:
    https://forum-en.msi.com/index.php?board=27.0

  • Maximum number of concurrent connections using java sockets

    How can we find out the maximum number of concurrent connections that can be handled by a pooled connection server?
    I have a pooled server which creates a predefined number of handlers. Upon receiving a new request it accepts the connection and sends it to one of the handler.
    The solution works well for low number of concurrent connections - < 50 or 100
    But as the number increases there seems to be an issue
    1. Ignoring request even if i increase the handlers
    2. Increase in delay. [I feel that the listening thread is not getting the time slice to go read the socket for new requests]
    Any idea as to how i can solve this?
    Would an NIO socket help [am using the conventional java.io Serversocket, because my clients may not be non-blocking]??
    Any help would be appreciated.
    Anp

    There is no set maximum, but it is in the thousands on most platforms. I have a production server that handles tens of thousands of connections simultaneously. Most likely you have a bug in your code.

  • Trying to understand the Mac world

    I've had my IMac for nearly 2 years now but have struggled all the way to migrate from a Windows environment. There seem to be so many hurdles to overcome, not least due to the horribly closed Mac universe which has made accessing things like music files, and sharing documents, incredibly difficult.
    I've tried the One to One service, and asked questions at the Genius bar and via the Helpline, but rarely get a useful answer. Nice people sure, but I feel I'm dealing with staff that have been weaned on Apple (through Ipods etc) - they know a fair bit about Macs, but seemingly very little about Windows and therefore of limited help in getting from one to another. Try asking someone about FLAC audio files for example . . .
    Some of the sort of issues I'm struggling to sort out include;
    1) In Windows I can use the F4 key to 'repeat last action'. An incredibly useful feature when formatting a number of separate cells in a spreadsheet for example. Yet I can find no equivalent in the Mac world - I can't even see how I might configure my keyboard accordingly.
    2) Having more than one application open on the desktop at a time. For example I open Word (MS Office for Mac), I then open Excel so I can cut and paste a few bits and pieces. As soon as I open Excel, Word minimises and zooms down to the Dock.
    3) Screen sizes. Why oh why does my Mac insist on opening applications in a window it determines the size of ? For instance I open Numbers - on my 27" IMac it opens a window at best about 6" square, complete with tiny, almost unreadable fonts. Is there no way to get applications to open full screen, and in a set font size, by default ?
    4) Screen resizing - I guess this is a feature of the OS (Snow Leopard 10.6) - only available in the bottom right ahnd corner. Just means more shuffling of windows about to use it effectively. Why can't screen resizing be done from any side as in Windows ?
    And don't get me started on hardware - why does a 27" IMac get shipped with a tiny wireless keyboard ? Wireless is good for sure, but surely a desktop computer isn't trying to save space to the extent that ones loses the numeric keypad, and worst of all, the DELETE key (aaagagahgha). I've had to buy a wired version to get the functionality I need (along with some accesible USB sockets). And then there is the card reader that can only cope with SD, the USB sockets helpfully out of easy reach round the back (makes using a datastick a real pain) . . . .
    Perhaps I shouldn't have gone down the Mac route (but now I've got an IPad too so heaven help me) . . . .

    A couple of answers:
    1. Microsoft Mac Office apps use command-Y for repeat last action, but that appeard to be missing from Apple's own apps, so it might be a Microsoft-specific thing.
    2. The "open Excel and Word minimizes" issue is one I have not seen in something like 14 years of using them on Mac OSes on a few dozen Macs. Sorry. I honestly don't know how to do that, but it's worth asking Microsoft Support about it.
    3. Traditionally, Mac apps open windows in the sizes you left them in; that is, the size at which you last saved the document. I can't think of a better convention. The exception is the new full-screen view added in OS X 10.7 (Lion); you appear to have to enable that each time you use the doc. Consider this dueling conventions: For years, I hates using Windows machines precisely because it insisted on obscuring all the other open windows with the current document, which I found terribly unhelpful, in my case based on experience from older windowing environments.
    4. Lion changes resizing as well: you can now resize from any boundary of a window. Don't know, considering your antipathy to the Mac experience, if it's worth spending whatever Apple charges for Lion in your country for these last two features alone.
        If my memory serves, Apple's original wireless keyboard was a full one (home &c. keys, numeric keypad), and the delete with a right arrow key was near th ehome key, as on the wired keyboard. I'm guessing Apple's marketing and focus groups found most people who wanted wireless keyboard didn't care about the extra keys, ("I want to be able to stick this in my backpack") and vice versa for the size of the wired ones, but that is, again, just a guess. There are lots of third-0party Bluetooth wireless keybaord that work with the Mac --- and probably cheaper than Apple's (in every sense of the word "cheaper").
        You don't say which card formats other than SD you want to use, but the last micro-SD card I bought came with an SD-sized adapter, for what it's worth.
        I have to agree with the inconvenience of using USB (and FireWire, and now Thunderbolt) ports on the back of the iMac, but (a) Jonny Ives like "clean" design (sorry, bad attempt at blaming the issue on a Brit), and (b) brlieve it or not, you get used to roatating the iMac 90 degrees, craning your neck around, and inserting your bit of kit. And if you have an Apple wired keyboard, you can stick USB thumb drives into the ports at either end.
        I think most people who've used both Macs and Windows machines for a while agree that the first reaction to the "other" platform is irritation: "Why does this thing not do things the way I'm used to?" Just as I learned not to expect Windows to do things in a Mac OS-like way, I don't expect Macs to do things in a Windows-like manner. Not a great answer, but it's the way it is.
        Can't imagine this helped at all, but hope it at least cleared a few things up.

  • AJA IOLA and fire wire

    I'm confused. I am setting up a FCP system on a brand new G5 dual 2.7 gHz with a 375 GB hard drive. I am using an AJA IO LD for input. From what I read, I can't digitize to the internal hard drive if the AJA is also using this hard drive (which sort of seems like a waste of 300 GB of perfectly fine space). I will be using a DVCam DSR 80 and a Sony Beta UVW 1800? as component input sources. Can I digitize to an EXTERNAL 7200 RPM Firewire hard drive?

    Ronnie,
    I do have an extra firewire card - but its a recent extra to my system to simply increase the number of my firewire sockets.
    I've been using the AJA with the standard sockets for about a year with no problems, (observing the AJA / video deck thing that I mentioned in my previous post.)
    As to running the AJA with Firewire video decks / cameras:
    I've had conflicting advice as to whether a PCI card for extra firewire sockets helps with firewire conflicts when using the AJA and a firewire video deck.
    Some have said that the 400 and 800 sockets are on independent busses but again others have said that it may still get confused.
    Some say that the PCI card is on a completely different buss and so will not be confused with firewire connections on the actual Mac, others disagree.
    I prefer to avoid conflicts, (my life is complicated enough and I like to keep my edit suite in a friendly mood...) so I just run the AJA or the firewire DSR-11 deck.
    As to normal editing once the material is digitised, then feel free to run your AJA on a 400 port and a drive on either a 400 or 800 port.
    LEE.

Maybe you are looking for

  • Excel 2013 App Store group

    The App Store group is disable in My Excel 2013 application but is enabled in Word 2013. How can I fix this problem? I have Offcie 2013 Plus and have installed SP 1 Jim

  • Application to pen drive

    I developed an application that is installed on a USB stick, more running on a machine that does not have Adobe Air installed message appears: This application requires a version of Adobe AIR which cannot be found. Please download the latest version

  • Photosmart C4780 won't work with my new router.

    Hi I have been sent a new plusnet TG582n router after my old one broke and now my wireless printer won't work. I have tried uninstalling the software and connecting the printer via USB to reinstall on my windows 7 netbook but it came up with drivers

  • Can not attach pl/sql library issue

    Hi, While customizing forms,I copied seeded .fmb to my local machine where I installed forms10g - forms builder.I copied related .fmbs and .plls into my local directory i.e c:\forms_files.I checked forms_path in hkey_local_machine and added C:\forms_

  • Jp2ssv.dll slows down new tabs with IE7/Vista

    java version "1.6.0_11" Java(TM) SE Runtime Environment (build 1.6.0_11-b03) Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing) IE7/Vista Home Basic (SP1, ITA, x86) all fully updated. If the ActiveX plugin for IE7 named 'Java (tm) Plug-