Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 24th, 2003, 04:20 AM
Authorized User
 
Join Date: Jun 2003
Location: Madrid, Madrid, Spain.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can be created a Socket client in a Servlet?

I am trying to create in a Servlet a Shocket client.
The client makes a request, I must itself connect to a machine, to a concrete port, to pass a String to him and to gather the String that she gives me like answer.
I always obtain an error:
       Software caused connection abort: recv failed
It is had to create a thread by Socket obligatorily?
This my code:
      DataOutputStream os = null;
      DataInputStream is = null;
      try{
         if(clientSocket == null) {
            clientSocket = new Socket(host, port);
         }
         is = new DataInputStream(clientSocket.getInputStream());
         os = new DataOutputStream(clientSocket.getOutputStream());
         os.writeBytes(cadena);
         String response = is.readLine();
      }

      catch(Exception e) {
           System.out.println("ERROR: "+e.getMessage()+"--> "+e);
      }
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting client to client (Socket programming) maricar C# 0 September 25th, 2008 05:34 AM
Socket Programming lisamargaret C# 1 December 18th, 2007 10:20 AM
Send file from Servlet to Client End (Swing) nigam.anand Servlets 0 April 22nd, 2006 03:22 AM
sending a file from swing client to servlet sid_ Servlets 0 March 2nd, 2005 05:18 PM
connecting a Swing client to an existing servlet a jcarlier Java GUI 1 June 17th, 2004 06:33 PM



All times are GMT -4. The time now is 03:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.