You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Micka <mi...@gmail.com> on 2011/05/16 18:18:20 UTC

TomCat 7 + Socket & Java Version

Hi,

I've an application that is running under Tomcat7.
And I 've created a serversocket, in my PC, the application is running
without problem.
But when I place the application in my linux machine, I observed a problem
in the socket communication.

To check if the client received correctly the data, it sent me back an echo.
In my case, the echo is always wrong. But on my PC the echo works well.

I don't understand what is wrong !

So I'm asking to the specialist, is it possible that the problem comes from
the different version of java that i used ?


Server Tomcat7 config :


mickael@P:/usr/local/tomcat7/bin$ sh version.sh
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-6-sun
Using CLASSPATH:
/usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.12
Server built:   Apr 1 2011 06:13:02
Server number:  7.0.12.0
OS Name:        Linux
OS Version:     2.6.32-24-server
Architecture:   amd64
JVM Version:    1.6.0_24-b07
JVM Vendor:     Sun Microsystems Inc.



And on my PC ( windows 7 ) config :
tomcat version : apache-tomcat-7.0.8
JRE: jre6 ( standard VM ) .

Re: TomCat 7 + Socket & Java Version

Posted by André Warnier <aw...@ice-sa.com>.
Micka wrote:
> Well because I thought that hosting a java server application by Tomcat is
> just perfect !
> 
> You can control a lot of thing, and you can create jsp page for
> administration purpose.
> 
> 
> 
> Do you have better than Tomcat for hosting a java server application ?

No, no, you are right, and it is a clever thing to do.  There is already a lot of 
"infrastructure" in Tomcat that can be used to do other things than just running HTTP 
servlets to return html pages.
It just is not something that is very often exploited.  Good idea.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by David kerber <dc...@verizon.net>.
On 5/17/2011 10:12 AM, Micka wrote:
> Well because I thought that hosting a java server application by Tomcat is
> just perfect !
>
> You can control a lot of thing, and you can create jsp page for
> administration purpose.
>
>
>
> Do you have better than Tomcat for hosting a java server application ?

I think what he's saying is that your app is duplicating a lot of what 
Tomcat does, and it looks like it doesn't need tomcat at all (in other 
words, it doesn't need to be hosted; it is its own server).


>
>
>
> On Tue, May 17, 2011 at 4:03 PM, André Warnier<aw...@ice-sa.com>  wrote:
>
>> Micka wrote:
>>
>>> Thx for the advise, My mail will be better for the next time.
>>>
>>> To explain better my application, it is a TCP server. And it received
>>> connection requests from clients.
>>>
>>> In my configuration I'm automatically waiting and accepting a connection
>>> with :
>>>
>>> java.net.ServerSocket.accept()
>>>
>>>
>>> After that I give the socket to a Thread to communicate with the device.
>>>
>>>
>>> In my case the device, works with commands. And to check if there is no
>>> errors during the communication, It send me back an echo.
>>> Each time that i send a command, I check if the echo is the same, if not,
>>> I
>>> create an Exception.
>>>
>>>
>>> is that better ? :p
>>>
>>>
>> Yes, now it is starting to make sense.
>> The "devices" (which are not browsers), are actually TCP clients, but after
>> establishing a connection with the server (your application), they become
>> "passive" and wait for further commands from your Tomcat application.
>>
>> :-)
>>
>> So now, and purely by curiosity, whhy is your application then hosted under
>> Tomcat, if it is already its own TCP server and manages its own threads ?
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Micka <mi...@gmail.com>.
Well because I thought that hosting a java server application by Tomcat is
just perfect !

You can control a lot of thing, and you can create jsp page for
administration purpose.



Do you have better than Tomcat for hosting a java server application ?



On Tue, May 17, 2011 at 4:03 PM, André Warnier <aw...@ice-sa.com> wrote:

> Micka wrote:
>
>> Thx for the advise, My mail will be better for the next time.
>>
>> To explain better my application, it is a TCP server. And it received
>> connection requests from clients.
>>
>> In my configuration I'm automatically waiting and accepting a connection
>> with :
>>
>> java.net.ServerSocket.accept()
>>
>>
>> After that I give the socket to a Thread to communicate with the device.
>>
>>
>> In my case the device, works with commands. And to check if there is no
>> errors during the communication, It send me back an echo.
>> Each time that i send a command, I check if the echo is the same, if not,
>> I
>> create an Exception.
>>
>>
>> is that better ? :p
>>
>>
> Yes, now it is starting to make sense.
> The "devices" (which are not browsers), are actually TCP clients, but after
> establishing a connection with the server (your application), they become
> "passive" and wait for further commands from your Tomcat application.
>
> :-)
>
> So now, and purely by curiosity, whhy is your application then hosted under
> Tomcat, if it is already its own TCP server and manages its own threads ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: TomCat 7 + Socket & Java Version

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 5/17/2011 10:03 AM, André Warnier wrote:
> Yes, now it is starting to make sense.
> The "devices" (which are not browsers), are actually TCP clients, but
> after establishing a connection with the server (your application), they
> become "passive" and wait for further commands from your Tomcat
> application.

Sounds like a botnet. :(

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3SiHkACgkQ9CaO5/Lv0PBeIQCgr4JMNt4K7LQGAXeayFdXmD+C
+b0AoKsmMe8J3bldq4sHXQtOJAjk6JwS
=GseY
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by André Warnier <aw...@ice-sa.com>.
Micka wrote:
> Thx for the advise, My mail will be better for the next time.
> 
> To explain better my application, it is a TCP server. And it received
> connection requests from clients.
> 
> In my configuration I'm automatically waiting and accepting a connection
> with :
> 
> java.net.ServerSocket.accept()
> 
> 
> After that I give the socket to a Thread to communicate with the device.
> 
> 
> In my case the device, works with commands. And to check if there is no
> errors during the communication, It send me back an echo.
> Each time that i send a command, I check if the echo is the same, if not, I
> create an Exception.
> 
> 
> is that better ? :p
> 

Yes, now it is starting to make sense.
The "devices" (which are not browsers), are actually TCP clients, but after establishing a 
connection with the server (your application), they become "passive" and wait for further 
commands from your Tomcat application.

:-)

So now, and purely by curiosity, whhy is your application then hosted under Tomcat, if it 
is already its own TCP server and manages its own threads ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Micka <mi...@gmail.com>.
Thx for the advise, My mail will be better for the next time.

To explain better my application, it is a TCP server. And it received
connection requests from clients.

In my configuration I'm automatically waiting and accepting a connection
with :

java.net.ServerSocket.accept()


After that I give the socket to a Thread to communicate with the device.


In my case the device, works with commands. And to check if there is no
errors during the communication, It send me back an echo.
Each time that i send a command, I check if the echo is the same, if not, I
create an Exception.


is that better ? :p







On Tue, May 17, 2011 at 3:26 PM, André Warnier <aw...@ice-sa.com> wrote:

> Micka,
>
> I'm glad that someone could help you after you provide better/clearer
> information.
>
> Just for future reference :
>
>
> Micka wrote:
>
>> Ok,
>>
>> Machine A :
>> OS : Windows Seven
>> JVM : jre6
>> Tomcat :  v7.0.8
>>
>> Machine B :
>> OS : Ubuntu 10.04
>> Using CATALINA_BASE:   /usr/local/tomcat7
>> Using CATALINA_HOME:   /usr/local/tomcat7
>> Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
>> Using JRE_HOME:        /usr/lib/jvm/java-6-sun
>> Using CLASSPATH:
>>
>> /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
>> Server version: Apache Tomcat/7.0.12
>> Server built:   Apr 1 2011 06:13:02
>> Server number:  7.0.12.0
>> OS Name:        Linux
>> OS Version:     2.6.32-24-server
>> Architecture:   amd64
>> JVM Version:    1.6.0_24-b07
>> JVM Vendor:     Sun Microsystems Inc.
>>
>>
> Very good.  With that kind of information, people here know the basics of
> your system(s), and can help much quicker and better, as you have seen.
>
>
>
>>
>>
>>
>> B) What I do :
>> step 1 : start TomCat on the server
>> step 2 : Looking at the log :
>> step 3 : The application works as a TCP server.
>> step 4 : a connection is established with a client
>> step 5 : the server send   1 1 1 5 *252* 2 6 1   ( char array ) to a
>> client
>> step 6 : the client confirmed the data by sending back an echo :   1 1 1 5
>> *
>> 63* 2 6 1
>> step 7 : the server detect that the echo is different of what It sent, it
>> resend the data.
>> step 8 : jump to step 5
>>
>>
> That is better than before, but still a bit confusing :
>
> In step 3, you say that the application works as a server.
> OK. That is what one usually expects from a Tomcat application.
> But,
> In step 4, you say that a connection is established with a client.
>
> That is confusing, because in the TCP protocol, it is a client which
> establishes the connection with a server.  The server opens a "listening"
> socket, and then just waits for client connections.  A client establishes a
> connection with that server socket, and then normally it is the client which
> sends something to the server (a request, a command,..), and the server
> responds.  Then the connection may be closed, or it may stay open, allowing
> for another client request and server response.
> That is how HTTP works, and in the Tomcat environment and on this list,
> most people would expect that, by default, you are talking about HTTP
> requests/responses.
>
> So basically at this point, you have most of us confused.
>
> It gets even more confusing, because you never tell us what this "client"
> really is, and why it would "echo" something back to the "server".
> So that is why you are not getting a lot of responses.
>
> Except from a guru like Konstantin, who was able to brilliantly sift
> through the obscure explanation, and devine that your basic problem may just
> be a question of character encoding.
> But you should not take this as a general rule.  The people here are
> generally good, but they only have their genius moments from time to time.
>
> Reviewing your above explanation (for the 3rd time), I would now think that
> in fact, your Tomcat application works as a TCP client, not as a server.  It
> is this application which creates its own client connection with some other
> server, right ?  And it is that other server which sends back an echo of the
> data, right ? Or am I still confused ?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: TomCat 7 + Socket & Java Version

Posted by André Warnier <aw...@ice-sa.com>.
Micka,

I'm glad that someone could help you after you provide better/clearer information.

Just for future reference :

Micka wrote:
> Ok,
> 
> Machine A :
> OS : Windows Seven
> JVM : jre6
> Tomcat :  v7.0.8
> 
> Machine B :
> OS : Ubuntu 10.04
> Using CATALINA_BASE:   /usr/local/tomcat7
> Using CATALINA_HOME:   /usr/local/tomcat7
> Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
> Using JRE_HOME:        /usr/lib/jvm/java-6-sun
> Using CLASSPATH:
> /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
> Server version: Apache Tomcat/7.0.12
> Server built:   Apr 1 2011 06:13:02
> Server number:  7.0.12.0
> OS Name:        Linux
> OS Version:     2.6.32-24-server
> Architecture:   amd64
> JVM Version:    1.6.0_24-b07
> JVM Vendor:     Sun Microsystems Inc.
> 

Very good.  With that kind of information, people here know the basics of your system(s), 
and can help much quicker and better, as you have seen.

> 
> 
> 
> 
> B) What I do :
> step 1 : start TomCat on the server
> step 2 : Looking at the log :
> step 3 : The application works as a TCP server.
> step 4 : a connection is established with a client
> step 5 : the server send   1 1 1 5 *252* 2 6 1   ( char array ) to a client
> step 6 : the client confirmed the data by sending back an echo :   1 1 1 5 *
> 63* 2 6 1
> step 7 : the server detect that the echo is different of what It sent, it
> resend the data.
> step 8 : jump to step 5
> 

That is better than before, but still a bit confusing :

In step 3, you say that the application works as a server.
OK. That is what one usually expects from a Tomcat application.
But,
In step 4, you say that a connection is established with a client.

That is confusing, because in the TCP protocol, it is a client which establishes the 
connection with a server.  The server opens a "listening" socket, and then just waits for 
client connections.  A client establishes a connection with that server socket, and then 
normally it is the client which sends something to the server (a request, a command,..), 
and the server responds.  Then the connection may be closed, or it may stay open, allowing 
for another client request and server response.
That is how HTTP works, and in the Tomcat environment and on this list, most people would 
expect that, by default, you are talking about HTTP requests/responses.

So basically at this point, you have most of us confused.

It gets even more confusing, because you never tell us what this "client" really is, and 
why it would "echo" something back to the "server".
So that is why you are not getting a lot of responses.

Except from a guru like Konstantin, who was able to brilliantly sift through the obscure 
explanation, and devine that your basic problem may just be a question of character encoding.
But you should not take this as a general rule.  The people here are generally good, but 
they only have their genius moments from time to time.

Reviewing your above explanation (for the 3rd time), I would now think that in fact, your 
Tomcat application works as a TCP client, not as a server.  It is this application which 
creates its own client connection with some other server, right ?  And it is that other 
server which sends back an echo of the data, right ? Or am I still confused ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Micka <mi...@gmail.com>.
Ok,

Machine A :
OS : Windows Seven
JVM : jre6
Tomcat :  v7.0.8

Machine B :
OS : Ubuntu 10.04
Using CATALINA_BASE:   /usr/local/tomcat7
Using CATALINA_HOME:   /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-6-sun
Using CLASSPATH:
/usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.12
Server built:   Apr 1 2011 06:13:02
Server number:  7.0.12.0
OS Name:        Linux
OS Version:     2.6.32-24-server
Architecture:   amd64
JVM Version:    1.6.0_24-b07
JVM Vendor:     Sun Microsystems Inc.





B) What I do :
step 1 : start TomCat on the server
step 2 : Looking at the log :
step 3 : The application works as a TCP server.
step 4 : a connection is established with a client
step 5 : the server send   1 1 1 5 *252* 2 6 1   ( char array ) to a client
step 6 : the client confirmed the data by sending back an echo :   1 1 1 5 *
63* 2 6 1
step 7 : the server detect that the echo is different of what It sent, it
resend the data.
step 8 : jump to step 5

C) The problem :
In step B-6, I am expecting 1 1 1 5 *252* 2 6 1 , but I get 1 1 1 5 *63* 2 6
1 ( it should be the same of the information that I sent, because It is an
echo )

D) Information : the function used to send the char array is : void
java.io.PrintWriter.write( char[] buf )


Thx for the support,




On Tue, May 17, 2011 at 10:59 AM, André Warnier <aw...@ice-sa.com> wrote:

> Micka,
>
> about the only things that I think I understand in your explanations are :
> - that you have two tomcats, one under Windows and one under Linux
> - that you have one application, as a war file, that you are trying in
> these two tomcats
> - that something seems to be different
>
> Apart from that, the rest of your explanations are not understandable, so
> we cannot even begin to guess if there is a problem or what the problem is,
> and thus we cannot help.
>
> Can you try again, starting from the beginning, and try to tell us exactly
> what you are doing step by step, what you expected, and why you think there
> is a problem ?
>
> Follow this plan :
>
> A) environment :
>
> Machine A :
> OS : ...  (version)
> JVM : ...  (version)
> Tomcat : ... (version)
>
> Machine B :
> OS : ...  (version)
> JVM : ...  (version)
> Tomcat : ... (version)
>
> Machine C (your workstation)
> OS : ...  (version)
> client used :   (browser ?)
>
> B) What I do :
> step 1 : .....
> step 2 : ....
> step 3 : ....
>
> C) The problem :
> In step B-3, I am expecting .......  , but I get .........
>
> OK ?
>
>
>
> Micka wrote:
>
>> Hi,
>>
>> I'm not saying that it's a fault of TomCat, I'm just saying that I've a
>> problem on a different machine.
>>
>> The problem, that I observe is on the echo. ( the echo is a little bit
>> different
>> The communication works well on my PC ( Tomcat7 under windows 7 )
>> But when I put the application ( .war ) on my linux machine with Tomcat7.
>> It
>> seems that the communication didn't work well.
>> I don't know why, because it's the same code, the same war file.
>>
>> some information about the test case :
>>
>> 10:27:32   => 01010105fc020601
>> =>1:1:1:5:252:2:6:1:
>> <= 1:1:1:5:63:2:6:1:
>> 10:27:32  <= 010101053f020601
>>
>> as you can see, the echo is a little bit different ! I don't understand
>> why,
>> it can't be !
>>
>> I'm using the function
>>
>> void
>> java.io.PrintWriter<eclipse-javadoc:%E2%98%82=LMJ_SERVEUR/C:%5C/Program%20Files%5C/Java%5C/jre6%5C/lib%5C/rt.jar%3Cjava.io%28PrintWriter.class%E2%98%83PrintWriter>.write(char[]
>>
>> buf)
>>
>>
>> If someone has an idea of what it can be, i'm very interesting !
>>
>>
>> Thx,
>>
>> On Mon, May 16, 2011 at 6:47 PM, Christopher Schultz <
>> chris@christopherschultz.net> wrote:
>>
>>  -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Micka,
>>>
>>> On 5/16/2011 12:18 PM, Micka wrote:
>>>
>>>> I've an application that is running under Tomcat7.
>>>> And I 've created a serversocket, in my PC, the application is running
>>>> without problem.
>>>> But when I place the application in my linux machine, I observed a
>>>>
>>> problem
>>>
>>>> in the socket communication.
>>>>
>>> What problem did you observe?
>>>
>>>  To check if the client received correctly the data, it sent me back an
>>>>
>>> echo.
>>>
>>>> In my case, the echo is always wrong. But on my PC the echo works well.
>>>>
>>> Client or server of both on PC in this case?
>>>
>>>  So I'm asking to the specialist, is it possible that the problem comes
>>>>
>>> from
>>>
>>>> the different version of java that i used ?
>>>>
>>> You haven't provided enough information for anyone to help. It's not
>>> even clear that this has anything to do with Tomcat.
>>>
>>> - -chris
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.10 (MingW32)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>>
>>> iEYEARECAAYFAk3RVQYACgkQ9CaO5/Lv0PAwMgCghz5sArtQrtdjCgCAnCosLukv
>>> VW8An1FN9bS50tK9Y3VlA7wwSzZDX+Uo
>>> =vBsl
>>> -----END PGP SIGNATURE-----
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: TomCat 7 + Socket & Java Version

Posted by André Warnier <aw...@ice-sa.com>.
Micka,

about the only things that I think I understand in your explanations are :
- that you have two tomcats, one under Windows and one under Linux
- that you have one application, as a war file, that you are trying in these two tomcats
- that something seems to be different

Apart from that, the rest of your explanations are not understandable, so we cannot even 
begin to guess if there is a problem or what the problem is, and thus we cannot help.

Can you try again, starting from the beginning, and try to tell us exactly what you are 
doing step by step, what you expected, and why you think there is a problem ?

Follow this plan :

A) environment :

Machine A :
OS : ...  (version)
JVM : ...  (version)
Tomcat : ... (version)

Machine B :
OS : ...  (version)
JVM : ...  (version)
Tomcat : ... (version)

Machine C (your workstation)
OS : ...  (version)
client used :   (browser ?)

B) What I do :
step 1 : .....
step 2 : ....
step 3 : ....

C) The problem :
In step B-3, I am expecting .......  , but I get .........

OK ?



Micka wrote:
> Hi,
> 
> I'm not saying that it's a fault of TomCat, I'm just saying that I've a
> problem on a different machine.
> 
> The problem, that I observe is on the echo. ( the echo is a little bit
> different
> The communication works well on my PC ( Tomcat7 under windows 7 )
> But when I put the application ( .war ) on my linux machine with Tomcat7. It
> seems that the communication didn't work well.
> I don't know why, because it's the same code, the same war file.
> 
> some information about the test case :
> 
> 10:27:32   => 01010105fc020601
> =>1:1:1:5:252:2:6:1:
> <= 1:1:1:5:63:2:6:1:
> 10:27:32  <= 010101053f020601
> 
> as you can see, the echo is a little bit different ! I don't understand why,
> it can't be !
> 
> I'm using the function
> 
> void java.io.PrintWriter<eclipse-javadoc:%E2%98%82=LMJ_SERVEUR/C:%5C/Program%20Files%5C/Java%5C/jre6%5C/lib%5C/rt.jar%3Cjava.io%28PrintWriter.class%E2%98%83PrintWriter>.write(char[]
> buf)
> 
> 
> If someone has an idea of what it can be, i'm very interesting !
> 
> 
> Thx,
> 
> On Mon, May 16, 2011 at 6:47 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Micka,
>>
>> On 5/16/2011 12:18 PM, Micka wrote:
>>> I've an application that is running under Tomcat7.
>>> And I 've created a serversocket, in my PC, the application is running
>>> without problem.
>>> But when I place the application in my linux machine, I observed a
>> problem
>>> in the socket communication.
>> What problem did you observe?
>>
>>> To check if the client received correctly the data, it sent me back an
>> echo.
>>> In my case, the echo is always wrong. But on my PC the echo works well.
>> Client or server of both on PC in this case?
>>
>>> So I'm asking to the specialist, is it possible that the problem comes
>> from
>>> the different version of java that i used ?
>> You haven't provided enough information for anyone to help. It's not
>> even clear that this has anything to do with Tomcat.
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iEYEARECAAYFAk3RVQYACgkQ9CaO5/Lv0PAwMgCghz5sArtQrtdjCgCAnCosLukv
>> VW8An1FN9bS50tK9Y3VlA7wwSzZDX+Uo
>> =vBsl
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Micka,

On 5/17/2011 5:44 AM, Micka wrote:
> I used write(char [])  because I didn't found a function to send a byte
> array ^^ .

Right: PrintWriter isn't appropriate for sending a byte array. Instead,
use an OutputStream (response.getOutputStream) instead.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3SiGMACgkQ9CaO5/Lv0PA4IQCcCSNiKsqcTfMtLHK75PblU+xK
P8MAn0rnCwRDF9oxtUxPGkq/lu7stTys
=Ouw2
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Micka <mi...@gmail.com>.
Thx for the help, It was indeed a problem of encoding setting ....

I added :

                bwriter = new PrintWriter( new BufferedWriter(new
OutputStreamWriter(soc.getOutputStream(), "Windows-1252")) );
                breader = new BufferedReader( new InputStreamReader(
soc.getInputStream(), "Windows-1252" ) );


But I thought on my function that it wasn't a problem, but after some
research I understand now better the difference .

I used write(char [])  because I didn't found a function to send a byte
array ^^ .

It's working well now, thx for the help !


On Tue, May 17, 2011 at 11:20 AM, Konstantin Kolinko <knst.kolinko@gmail.com
> wrote:

> 2011/5/17 Micka <mi...@gmail.com>:
> > void java.io.PrintWriter.write(char[] buf)
>
> Do you know about the difference between byte and char, between
> OutputStream and Writer? That is Java IO basics.
>
> The common pitfall is that different OSes usually have different
> default character encoding setting (e.g. "Windows-1252" vs. "UTF-8").
>
>
> BTW, the correct spelling of the server name is "Tomcat".
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: TomCat 7 + Socket & Java Version

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/5/17 Micka <mi...@gmail.com>:
> void java.io.PrintWriter.write(char[] buf)

Do you know about the difference between byte and char, between
OutputStream and Writer? That is Java IO basics.

The common pitfall is that different OSes usually have different
default character encoding setting (e.g. "Windows-1252" vs. "UTF-8").


BTW, the correct spelling of the server name is "Tomcat".

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: TomCat 7 + Socket & Java Version

Posted by Micka <mi...@gmail.com>.
Hi,

I'm not saying that it's a fault of TomCat, I'm just saying that I've a
problem on a different machine.

The problem, that I observe is on the echo. ( the echo is a little bit
different
The communication works well on my PC ( Tomcat7 under windows 7 )
But when I put the application ( .war ) on my linux machine with Tomcat7. It
seems that the communication didn't work well.
I don't know why, because it's the same code, the same war file.

some information about the test case :

10:27:32   => 01010105fc020601
=>1:1:1:5:252:2:6:1:
<= 1:1:1:5:63:2:6:1:
10:27:32  <= 010101053f020601

as you can see, the echo is a little bit different ! I don't understand why,
it can't be !

I'm using the function

void java.io.PrintWriter<eclipse-javadoc:%E2%98%82=LMJ_SERVEUR/C:%5C/Program%20Files%5C/Java%5C/jre6%5C/lib%5C/rt.jar%3Cjava.io%28PrintWriter.class%E2%98%83PrintWriter>.write(char[]
buf)


If someone has an idea of what it can be, i'm very interesting !


Thx,

On Mon, May 16, 2011 at 6:47 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Micka,
>
> On 5/16/2011 12:18 PM, Micka wrote:
> > I've an application that is running under Tomcat7.
> > And I 've created a serversocket, in my PC, the application is running
> > without problem.
> > But when I place the application in my linux machine, I observed a
> problem
> > in the socket communication.
>
> What problem did you observe?
>
> > To check if the client received correctly the data, it sent me back an
> echo.
> > In my case, the echo is always wrong. But on my PC the echo works well.
>
> Client or server of both on PC in this case?
>
> > So I'm asking to the specialist, is it possible that the problem comes
> from
> > the different version of java that i used ?
>
> You haven't provided enough information for anyone to help. It's not
> even clear that this has anything to do with Tomcat.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk3RVQYACgkQ9CaO5/Lv0PAwMgCghz5sArtQrtdjCgCAnCosLukv
> VW8An1FN9bS50tK9Y3VlA7wwSzZDX+Uo
> =vBsl
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: TomCat 7 + Socket & Java Version

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Micka,

On 5/16/2011 12:18 PM, Micka wrote:
> I've an application that is running under Tomcat7.
> And I 've created a serversocket, in my PC, the application is running
> without problem.
> But when I place the application in my linux machine, I observed a problem
> in the socket communication.

What problem did you observe?

> To check if the client received correctly the data, it sent me back an echo.
> In my case, the echo is always wrong. But on my PC the echo works well.

Client or server of both on PC in this case?

> So I'm asking to the specialist, is it possible that the problem comes from
> the different version of java that i used ?

You haven't provided enough information for anyone to help. It's not
even clear that this has anything to do with Tomcat.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3RVQYACgkQ9CaO5/Lv0PAwMgCghz5sArtQrtdjCgCAnCosLukv
VW8An1FN9bS50tK9Y3VlA7wwSzZDX+Uo
=vBsl
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org