• Post Reply Bookmark Topic Watch Topic
  • New Topic

socket communication to push data to client  RSS feed

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write a Java application to send a data
file output by a C program running on the server to a client
connecting to our web site. Once the file is downloaded to the
client machine I want to invoke a local program on the client
machine and pass the data file in as input. The
connection has to be secured. The initiation
of data transfer has to be on the server side since the client
doesn't know when the C program will finish writing the file.
I'm thinking of writing a client/server application that will
communicate through secured socket using Sun's Jsse. The client
will connect to the server and listen. When the server
gets notified via socket that the data file is ready it will
send the data to the listening client to be written out.
I'm a Java novice so I don't know whether it can be done
like this or if there's an easier altenative that I should
look into. So my questions are:
1. Is this feasible given the security issues (secured
connection, firewall)?
2. How do I notify the server from within the C program
that the file is ready to be sent?

3. Is there an easier alternative? We have
Apache Web server + SSL so if I can use the Web server's
provided support for https without using Sun's Jsse
that will be great. Is signed applet/servlet an alternative?
Thanks in advance for any help you can provide. It's urgent
that I come up with a solution so any help is appreciated.
Edward Man
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your client is a Java applet, you can't download a file to the client machine. The java security manager prohibits that. The client has to be a application. It can be written in Java, C, or whatever.
If there is a firewall in between, you cannot create a socket connection, the firewall does not allow that, unless your firewall administrator gives you a specific port no. The usual way is to use firewall tunnelling technique that uses GET or POST methods.
If you want to notify the server program from the C program, you can use socket connection (provided there is no firewall in between). Or use a pipe if they reside on the same machine. Or let the server program read the directory where the output file of the C program will store. It can read the file if it is there. It means some polling is needed.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!