Hi all.

I want to send xml data from a parent applet to a child applet
through socket communication.


So, for experiment, I made 2 applets as bellow.
But they don't work at all...

As you see, send-to-local-app.dcurl tries to connect the port 6001
on localhost.
But CouldntConnectSocketException which says the attempt to connect
to the port 6001 was refused always happens.

This is my first experience to use both AppletData and Socket at
the same time and I have no idea to solve this problem at now.

Please tell me where is wrong.

---------------------------- listner.dcurl --------------------------
{curl 4.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}

{import * from CURL.IO.SOCKET}

{let listener:AcceptorTCPSocket = {AcceptorTCPSocket
                                      local-address = {SocketInetAddress
SocketInetAddress.local-host},
                                      local-port = 6001
                                  }
}

{define-proc {accept-handler e:AcceptableSocketEvent}:void
    let sock:DataTCPSocket = {listener.accept}
    let input:TranscodingTextInputStream = {TranscodingTextInputStream
                                               {sock.to-InputStream}}
    {while false == input.end-of-stream? do
        let c:char = {input.read-one}
        {output c}
    }
}

{do
    {listener.add-event-handler
        {on e:AcceptableSocketEvent do
            {accept-handler e}
        }
    }

    {if listener.open? then
        {listener.close}
    }

    {listener.bind}
}

-------------------- send-to-local-app.dcurl ----------------------
{curl 4.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}

{import * from CURL.ENGINE.BROWSER}
{import * from CURL.IO.SOCKET}

{let another-applet:AppletData = {AppletData
                                     null,
                                     {url "listener.dcurl"}
                                 }
}


{register-exit-proc {proc {}:void
                        {another-applet.destroy}
                    }
}

{do
    let s:String = "ABCDEFG"
    let bv:ByteVec = {ByteVec max-size = 7}

    {encode-characters
        s,
        bv,
        {get-character-encoding-by-name "shift-jis"}
    }

    {sleep 5s}

    let sender:DataTCPSocket = {DataTCPSocket
                                   remote-address = {SocketInetAddress
SocketInetAddress.local-host},
                                   remote-port = 6001
                               }
    {sender.connect}

    let output:DataSocketByteOutputStream = {sender.to-OutputStream}

    {for i:int = 0 to 6 do
        {output.write-one bv[i]}
    }

    {sender.shutdown DataSocketShutdownOption.input-output}
}



regards.
--Maekawa

*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to