Java Socket read problem
Shani
shani.runrev at gmail.com
Tue Apr 6 13:54:28 EDT 2010
HI,
I have problem with the revcode. It cant display
This result.
Server Started
Client Syas: AllowServer
I start the process then write "AllowServer" as a client but it cant work.
Kindly tell me on which line is the problem,
Java program is working. Th eproblem is rev side.
StartProcessButton
################################################3
on mouseUp
local tDefaultFolder, tProcess
--
put the defaultFolder into tDefaultFolder
set the defaultFolder to StackPath()
--
put "java Server 54321" into tProcess
open process tProcess for neither
--
set the defaultFolder to tDefaultFolder
end mouseUp
##########################################
Socketbutton
###########################################
on mouseUp
local tDefaultFolder, tResult, tSocket
--
put ("localhost:54321") into tSocket
open socket tSocket
write "AllowServer" & return to socket tResult
answer tResult
end mouseUp
############################################
function StackPath
local tPath
--
put the effective filename of this stack into tPath
set the itemDelimiter to slash
delete item -1 of tPath
--
return tPath
end StackPath
Java coding:
import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main (String[] args) throws IOException{
ServerSocket server=new ServerSocket(54321);
System.out.println("Server Started");
Socket client= server.accept();
DataInputStream in= new DataInputStream(client.getInputStream());
System.out.println("Client Syas: " + in.readUTF());
}
}
You can see the example on this link:
http://www.4shared.com/file/258393507/808220ec/javaServer.html
Regards,
SHANI
More information about the use-livecode
mailing list