You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by leecholho <ro...@hotmail.com> on 2007/08/14 03:48:48 UTC

problem the communication to cross-platform(flash)..

hi.. 
i'm testing a modified source of sample chat server source.. client program
is flash,

flash transmitted message that added "\r\n" to the message.
and java server(multi-thread base) is return message that added "\0" to the
return message.

i used same source the recevie and send part. first message is not problem.
server is recevied and return ok message the client, and client is recevied
ok message. but client next message is sent to server, server received empty
message.

what is problem?
[ client source ]
function handleIncoming (messageObj) {
	var tag=messageObj.firstChild.firstChild.nodeValue;
	if(tag == "LOGINS"){
		mySocket.send("PN\r\n");
	} 
}
mySocket.connected = true;
mySocket.send("LOGIN"+"\t"+userid+"\r\n");
[ /client source]

[server source]
 public void messageReceived(IoSession session, Object message) {
        Vector vectorTmp = new Vector(); 
        String theMessage = (String) message; 
        System.out.println("theMessage = "+theMessage+", user="+(String)
session.getAttribute("user"));

        StringTokenizer str=new StringTokenizer(theMessage, "\t");	
        while(str.hasMoreTokens()){ vectorTmp.addElement(str.nextToken()); }
        String theCommand = vectorTmp.elementAt(0).toString();
        String UserID = vectorTmp.elementAt(1).toString();
        if ("LOGIN".equals(theCommand)) {
                sessions.add(session);
	session.setAttribute("user", UserID);
	session.write("<head>LOGINS</head>\0");
        }
[/server source]

-- 
View this message in context: http://www.nabble.com/problem-the-communication-to-cross-platform%28flash%29..-tf4264788s16868.html#a12137370
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: problem the communication to cross-platform(flash)..

Posted by Trustin Lee <tr...@gmail.com>.
Please take a look at this thread:

http://www.nabble.com/sending-null-terminated-strings-tf4410525s16868.html

Trustin

On 8/14/07, leecholho <ro...@hotmail.com> wrote:
>
> thanks your replay..
> i checked a messages with Ethereal..
> and cheked that flash sent "0d 0a 00"
>
> i'm testing a several methods..
> 1) session.write("<head>LOGINS</head>");
>     last message is "0a" , flash is not  checked  get message..
> 2) session.write("<head>LOGINS</head>\r");
>     last message is "0d0a" , flash is not  checked  get message..
> 3)session.write("<head>LOGINS</head>\r\n");
>     last message is "0d0a0a" , flash is not  checked  get message..
> 4)session.write("<head>LOGINS</head>\0");
>     last message is "000a" , flash is checked  get message but java received
> empty message.
> 5)session.write("<head>LOGINS</head>\r\n\0");
>     last message is "0d0a000a" , flash is checked  get message but java
> received empty message.
>
>
>  i forgot the explain the before source , i used  out.flush();
> out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
>
>
>
> Trustin Lee wrote:
> >
> > On 8/14/07, leecholho <ro...@hotmail.com> wrote:
> >>
> >> hi..
> >> i'm testing a modified source of sample chat server source.. client
> >> program
> >> is flash,
> >>
> >> flash transmitted message that added "\r\n" to the message.
> >> and java server(multi-thread base) is return message that added "\0" to
> >> the
> >> return message.
> >>
> >> i used same source the recevie and send part. first message is not
> >> problem.
> >> server is recevied and return ok message the client, and client is
> >> recevied
> >> ok message. but client next message is sent to server, server received
> >> empty
> >> message.
> >>
> >> what is problem?
> >> [ client source ]
> >> function handleIncoming (messageObj) {
> >>         var tag=messageObj.firstChild.firstChild.nodeValue;
> >>         if(tag == "LOGINS"){
> >>                 mySocket.send("PN\r\n");
> >>         }
> >> }
> >> mySocket.connected = true;
> >> mySocket.send("LOGIN"+"\t"+userid+"\r\n");
> >> [ /client source]
> >
> > Doesn't the client send a trailing '\0' after \r\n?  Please try to use
> > a packet analyzer such as Wireshark to see what client is exactly
> > sending.  If the client is sending a NUL character, you can get an
> > empty string.  Please let me know what the client is sending, so I can
> > help you track down the problem.
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
> >
>
> --
> View this message in context: http://www.nabble.com/problem-the-communication-to-cross-platform%28flash%29..-tf4264788s16868.html#a12139898
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>


-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: problem the communication to cross-platform(flash)..

Posted by leecholho <ro...@hotmail.com>.
thanks your replay..
i checked a messages with Ethereal..  
and cheked that flash sent "0d 0a 00"

i'm testing a several methods..
1) session.write("<head>LOGINS</head>"); 
    last message is "0a" , flash is not  checked  get message..
2) session.write("<head>LOGINS</head>\r"); 
    last message is "0d0a" , flash is not  checked  get message..
3)session.write("<head>LOGINS</head>\r\n"); 
    last message is "0d0a0a" , flash is not  checked  get message..
4)session.write("<head>LOGINS</head>\0"); 
    last message is "000a" , flash is checked  get message but java received
empty message.
5)session.write("<head>LOGINS</head>\r\n\0"); 
    last message is "0d0a000a" , flash is checked  get message but java
received empty message.


 i forgot the explain the before source , i used  out.flush();  
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));



Trustin Lee wrote:
> 
> On 8/14/07, leecholho <ro...@hotmail.com> wrote:
>>
>> hi..
>> i'm testing a modified source of sample chat server source.. client
>> program
>> is flash,
>>
>> flash transmitted message that added "\r\n" to the message.
>> and java server(multi-thread base) is return message that added "\0" to
>> the
>> return message.
>>
>> i used same source the recevie and send part. first message is not
>> problem.
>> server is recevied and return ok message the client, and client is
>> recevied
>> ok message. but client next message is sent to server, server received
>> empty
>> message.
>>
>> what is problem?
>> [ client source ]
>> function handleIncoming (messageObj) {
>>         var tag=messageObj.firstChild.firstChild.nodeValue;
>>         if(tag == "LOGINS"){
>>                 mySocket.send("PN\r\n");
>>         }
>> }
>> mySocket.connected = true;
>> mySocket.send("LOGIN"+"\t"+userid+"\r\n");
>> [ /client source]
> 
> Doesn't the client send a trailing '\0' after \r\n?  Please try to use
> a packet analyzer such as Wireshark to see what client is exactly
> sending.  If the client is sending a NUL character, you can get an
> empty string.  Please let me know what the client is sending, so I can
> help you track down the problem.
> 
> HTH,
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-the-communication-to-cross-platform%28flash%29..-tf4264788s16868.html#a12139898
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: problem the communication to cross-platform(flash)..

Posted by Trustin Lee <tr...@gmail.com>.
On 8/14/07, leecholho <ro...@hotmail.com> wrote:
>
> hi..
> i'm testing a modified source of sample chat server source.. client program
> is flash,
>
> flash transmitted message that added "\r\n" to the message.
> and java server(multi-thread base) is return message that added "\0" to the
> return message.
>
> i used same source the recevie and send part. first message is not problem.
> server is recevied and return ok message the client, and client is recevied
> ok message. but client next message is sent to server, server received empty
> message.
>
> what is problem?
> [ client source ]
> function handleIncoming (messageObj) {
>         var tag=messageObj.firstChild.firstChild.nodeValue;
>         if(tag == "LOGINS"){
>                 mySocket.send("PN\r\n");
>         }
> }
> mySocket.connected = true;
> mySocket.send("LOGIN"+"\t"+userid+"\r\n");
> [ /client source]

Doesn't the client send a trailing '\0' after \r\n?  Please try to use
a packet analyzer such as Wireshark to see what client is exactly
sending.  If the client is sending a NUL character, you can get an
empty string.  Please let me know what the client is sending, so I can
help you track down the problem.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6