You can subscribe to this list here.
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: John H. <jo...@sh...> - 2004-02-13 20:44:09
|
Hi, I am trying to create a client client using jniosocket's to connect to a host and port (port 5038) where I am using the HTTP client as an example. A requirement is to keep the conversation going after connecting and be able to read and write to the connection. I have extended NioSocket but I am not having much luck. Part of the problem is I am not exactly sure of the exact methods I should using to accomplish this. Here is the code. Thanks for any help, John Haigh package raining.client; import raining.core.*; import java.net.URL; import org.apache.commons.cli.*; import java.io.*; import java.util.*; import sun.net.www.*; public class testClient extends NioSocket{ public static final String P = "AsteriskClient"; String host = null; String path = null; String GETString = null; int port = 5038; /** Creates a new instance of testClient */ public testClient() throws java.io.IOException, Exception { } public static void main(String[] args) { try { testClient t = new testClient (); t.setHostPort("192.168.1.11", 5038); t.push(); NioSocket.stopWhenIdle(true); NioSocket.start(); } catch (Exception exc) { System.err.println( " Http 21 EXC:"+ exc.toString()); exc.printStackTrace(); } } public void push () throws java.io.IOException, Exception { makeGETString(); System.out.println( "AsteriskClient 196 push() : GETSTRING:"+GETString+"p:"+port+"h:"+host); super.create_client_socket( host , port); } public void makeGETString() { GETString = "Action: Login\r\nUsername: john\r\nSecret: john\r\n\r\n"; } public testClient setHostPort(String hostname, int port) { this.host = hostname; this.port = port; return this; } public void handle_read_complete(String mdata){ System.out.println( mdata ); System.err.println( "S = " + id +" Total:" + totalBytesRead); if (debug){ if (totalBytesRead == 0) System.out.println( " XXXXXX " + id); } } public int handle_read() { int count = super.handle_read(); int pos; handle_read_complete( getReadData() ); handle_close(); return count; } // handle }} |