5

I am a java developer and quite aware of socket programming in java.I have a tcp server running my localmachine.I can write java codes for client and check communication between server and client.But I wanted to know if can communicate with the server from command prompt in windows.

I am using windows 7 operating system and the tcp port is 6002.So can any body please tell how to send data from windows command prompt

  • 1
    I don't care what anybody says but there is no such thing as a TCP server. You have a server that runs a process/service that communicates via TCP port 6002. That does not make it a TCP server. Have you tried using Telnet? – joeqwerty May 22 '14 at 16:36
  • 1
    @joeqwerty by telnet localhost 6002 I can connect with it.But I dont know how to send data – SpringLearner May 22 '14 at 16:38
  • 1
    Once you connect through telnet, you just start typing. The program will send what you type to the server, and print what the server sends back to your terminal. You would have to know what data you want to send to the server, of course. – Kenster May 22 '14 at 17:18
  • 1
    @joeqwerty: I've seen the term used to differentiate from something listening and only accepting UDP connections, i.e. in contrast to "UDP server." – LawrenceC May 22 '14 at 21:23
  • 2
    That's like saying a web server is an IP server, or a Data-Link Layer server. You could call it anything you want in relation to any of the 7 OSI layers. A server may use TCP as it's transport mechanism but that doesn't make it a TCP server. It does not serve TCP. A server serves. You can serve HTTP or HTTPS, or you can serve CIFS or NFS, but you can't serve TCP. – joeqwerty May 22 '14 at 23:26
1

Windows XP used to have a telnet command that was useful for "quick and dirty" testing if a TCP server was alive and reachable.

telnet {IP-address} {port}

i.e. telnet microsoft.com 80

If no service is listening, you will get an error message. If it's blocked by a firewall, it will timeout.

If the service outputs something upon connection, you will see it. However, it may be waiting for you to send something. In the case above, type GET / http/1.1, hit enter twice, and you'll see the HTML of http://microsoft.com.

With Windows 7, you can install the "Telnet Client" from Programs and Features -> Turn Windows features on or off, or use PuTTY for this purpose.

You can also use a better tool for this purpose called netcat.

| improve this answer | |
  • Thanks for answering.I have done a tcp server configuration which just listen at 6002 port and local ip.It will also accept binary data.so after receiving it will also acknoledge data in binary format.I have done both client and server in java.If I run both client and sever in java then it works properly(meaning sending and getting data).Just I am curious to know how to send data in telnet. Becuase when I do telnet localhost 6002 then it only connects to server and in the server console I can see client is connected.But I want to know how can I send data – SpringLearner May 23 '14 at 2:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.