Solved

server socket that can handle input and output

Posted on 2014-01-31
16
415 Views
Last Modified: 2014-03-10
Hi,

I am trying below example
http://www.avajava.com/tutorials/lessons/how-do-i-write-a-server-socket-that-can-handle-input-and-output.html

after i ran example and opened command prompt.
I gave command >>telnet localhost 81

i am getting error


C:\>telnet locahost 81
'telnet' is not recognized as an internal or external command,
operable program or batch file.


How to fix this.
what is the purpose of this example.

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 7
  • 7
  • 2
16 Comments
 
LVL 16

Expert Comment

by:krakatoa
ID: 39825460
Maybe I am not clear about your question, but a ServerSocket just sets up a Socket as an end-to-end connection with another host's socket, by implementing its .accept() method.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39825517
opened command prompt.
I gave command >>telnet localhost 81

i am getting error


C:\>telnet locahost 81
'telnet' is not recognized as an internal or external command,
operable program or batch file.



what it means by telnet not recognized. please advise.

ServerSocket just sets up a Socket as an end-to-end connection with another host's socket, by implementing its .accept() method.

why we need sockets and end to end connection. i never remember using them in real time projects myself. Please advise
0
 
LVL 16

Accepted Solution

by:
krakatoa earned 350 total points
ID: 39825606
why we need sockets and end to end connection

Programming Java is at the application level. The API (via sockets) will handle the low-level TCP stuff once you have established the connection in order to allow you the end-to-end communication channel with another host - computer.

Telnet is a protocol carried also over TCP. To leverage it, you have a handful of predefined keyword commands you can issue to convey to the other party (server or peer) what it is you want to 'say'. Not sure what further connection you have in mind between Telnet and Java. Here is part of the Telnet command set :

Commands may be abbreviated. Supported commands are:

c    - close                    close current connection
d    - display                  display operating parameters
o    - open hostname [port]     connect to hostname (default port 23).
q    - quit                     exit telnet
set  - set                      set options (type 'set ?' for a list)
sen  - send                     send strings to server
st   - status                   print status information
u    - unset                    unset options (type 'unset ?' for a list)
?/h  - help                     print help information
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 150 total points
ID: 39828670
'telnet' is not recognized as an internal or external command,
operable program or batch file.
Is nothing to do with Java or your server socket program at all. That is an error message from your Operating System saying that you don't have the telnet program installed. I am guessing that you are on a newer version of Windows where telnet doesn't get installed by default. As for getting it installed, since I don't know exactly what operating system you are using, refer to this link... http://technet.microsoft.com/en-us/library/cc771275(v=ws.10).aspx for further instructions.
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39829264
That is an error message from your Operating System saying that you don't have the telnet program installed.

There is a chance, also, that it is not that, but that you have a messed up reference to telnet in your environment variables, and so the OS can't find it. You might want to check that.

It would be pretty unusual that your OS hadn't bundled telnet.

(If you run Windows, you can search your hard disk like this :) dir C:\telnet.* /s
0
 
LVL 7

Author Comment

by:gudii9
ID: 39829934
i checked it is windows 7 enterprise operating system.
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39829947
i checked it is windows 7 enterprise operating system.

Yes, but did you run that little command I posted above, to see if telnet is resident?
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39831326
@krakatoa,
It would be pretty unusual that your OS hadn't bundled telnet.
If you have a look at the link that I posted above, the very first (informative) line on the page states:
Telnet Client is not installed by default on Windows 7, Windows Server 2008 R2, Windows Vista, or Windows Server 2008.
And note that I didn't say that it ISN'T included (bundled) with Windows, it's just that it isn't installed by default.

@gudii9,

Did you attempt to install Telnet using the instructions provided in the link above?
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39831887
If you have a look at the link that I posted above, the very first (informative) line on the page states:

I don't always have time to read links.

I'll remember not to "overinform" people next time.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39842765
when i tried above command

C:\Users\xyz001>C:\telnet.* /s
The system cannot find the path specified.

I got above message. I will try to install by following above link once I reach home from home laptop.
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39843012
No!

dir C:\telnet.* /s
0
 
LVL 7

Author Comment

by:gudii9
ID: 39857586
i see like

Volume in drive C is OSDisk
Volume Serial Number is AAAA-BBBB

please advise
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39857824
OK, so when it finishes the search, if it says :

"File not Found"

then you do not have telnet installed.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39867816
will try from home laptop later and let you know
0
 
LVL 7

Author Comment

by:gudii9
ID: 39878649
i tried from home laptop it did not work here as well.


I gave the command and looks like telnet is there


02/04/2014  10:19 AM            10,576 telnet.h
               1 File(s)         10,576 bytes

 Directory of C:\Windows\SoftwareDistribution\Download\bcfed137e95e2bc1b83ef8026
2a82b16\x86_microsoft-windows-telnet-client_31bf3856ad364e35_6.0.6002.18005_none
_ba1d0a71222c35d2

04/11/2009  01:28 AM            70,656 telnet.exe
               1 File(s)         70,656 bytes

 Directory of C:\Windows\winsxs\x86_microsoft-windows-t..et-client.resources_31b
f3856ad364e35_6.0.6000.16386_en-us_7ac6e3ffd37e7001

11/02/2006  07:41 AM            14,848 telnet.exe.mui
               1 File(s)         14,848 bytes

 Directory of C:\Windows\winsxs\x86_microsoft-windows-telnet-client_31bf3856ad36
4e35_6.0.6001.18000_none_b8319165250a6a86

01/20/2008  09:25 PM           206,336 telnet.exe
               1 File(s)        206,336 bytes

     Total Files Listed:
               5 File(s)        302,511 bytes
               0 Dir(s)  82,173,440,000 bytes free

C:\Users\ganesha>

Not sure when i say
telnet localhost 81

Server did not ask our name as given in link

The server asks us our name, so I typed 'Bob'. It says 'Hello, Bob' and then closes the connection.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39878652
My eclipse console showed when i ran program as below though
Creating server socket on port 81
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 58
fibonacci ten numbers 4 54
Android development question 2 75
Better way to make a string with template variables in java 3 31
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question