Win socket with applet socket by byte type data network

Server is windock
Client is applet
How do i receive and send byte type data..
What i do using sock type?
UDP? just i use Inputstream, Outputstream?
and i some warring..
Packet Buffering...
how do i?
plz help me...

Hi
Search the Forum for "socket", start reading other people questions and answers, i am sure that after spending few hours you will find some answers.
Noah

Similar Messages

  • Working with sockets with applets

    Hello, I am working in my account on a web server, and I am trying to develop a chat using applets. My program works great on the command line, but the applets cannot create a socket because of a SocketPermission problem. I have read about this problem a lot, and I found that applets will only create a socket with the server the applet originates from. I have still not had any success in allowing my applet to create a socket to connect to a server.
    I would appreciate any advice concerning this problem!
    Thanks so much!
    Christina

    If you are calling the HTML page containing the Applet as http://localhost then the Applet has to open a socket back to local host.
    Make sure you call the applet using the full ip address of the where the web server is running. This should match the socket ip address you are trying to open inside the Applet.

  • Using sockets with Applet

    Hey,
    I have a website which has an applet on one of the pages. I put in code that uses a socket to connect to MY computer. ( i want to use my computer as a server which stores data/accounts/etc) A SecurityException was thrown when I tested the applet. Is what I'm trying to do possible? or does something like this have to connect to a server which is on my website?
    Thanks

    I believe you can run something like this by signing the applet.
    And then the user has the option of allowing or disallowing a signed applet to do that kind of thing. I don't know which is the default.

  • Im Stuck, error in my server (j2se socket) with j2me (socket)

    I dunt understand, previous worked, now (2.3beta wireless toolkit) doenst work anymore, u guys can help me?
    SERVER CODE J2SE
    package com.pc.jwolf.server.testes;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class Teste01 {
         public Teste01() throws IOException {
              ServerSocket s = new ServerSocket(3131);
              Socket sx = s.accept();
              DataInputStream input = new DataInputStream(sx.getInputStream());
              DataOutputStream output = new DataOutputStream(sx.getOutputStream());
              output.flush();
              int c = 0;
              StringBuffer b = new StringBuffer();
              while((c=input.read()) != -1) b.append((char) c);
              System.out.println(new String(b));
         public static void main(String[] args) {
              try {
                   new Teste01();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }MOBILE CODE (J2ME) CLDC 1.1 Profile 2.0
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.SocketConnection;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    public class Midlet extends MIDlet {
         protected void startApp() throws MIDletStateChangeException {
              // TODO Auto-generated method stub
              try {
                   SocketConnection sc = (SocketConnection) Connector
                             .open("socket://127.0.0.1:3131");
                   DataInputStream input = sc.openDataInputStream();
                   DataOutputStream out = sc.openDataOutputStream();
                   out.flush();
                   out.writeUTF("HELLO WORLD!!!!!!");
                   out.flush();
              } catch (Exception e) {
                   // TODO: handle exception
                   e.printStackTrace();
         protected void pauseApp() {
              // TODO Auto-generated method stub
         protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
              // TODO Auto-generated method stub
    }My server cant read the message... whats wrong?
    Tkz.

    Hi,
    I the exact same problem. I didn't quite understand what you meant by closing the socket. When i close the socket on the server side before I enter the whole look it throws an exception. Could please help out and maybe paste a little code to explain further.
    Thank you

  • Issue with file download from BLOB type data

    i have been using this for a while, with no problems, including on hosted machines.
    the upload to the database works fine.. not the issue, and the download script also works fine, on the local WAMP machine.
    but once moved to the server it fails.. the query does not work.
    i have a feeling that it is something to do with the managed hosting i am using, but they say no, i have tried it on 2 seperate hosted machines (different providers), with no joy.
    if i run the select query on the hoisting server via phpmyadmin, the query runs ok.
    any suggestions as to what may be causing the problem on the server compared to the local WAMP machine?
    i really don't know where to start looking, or where to point the hosting company.
    This is the php code to download the blob data, works fine on local WAMP setup, browser asks if you want to save the file/open etc. as expected.
    <?php require_once('Connections/connTracker.php'); ?>
    <?php
    // if id is set then get the file with the id from database
    if(isset($_GET['docindex']))
               {$id    = $_GET['docindex'];
            $query = "SELECT document_name, document_type, document_size, document_content " .
               "FROM tracker_documents WHERE document_index = ".$id;
    *** seems to be failing here when running the query ***
    $result = mysql_query($query) or die('Error, query failed');
               list($name, $type, $size, $content) = mysql_fetch_array($result);
         header("Cache-Control: maxage=1"); //In seconds
       header("Pragma: public");
         header("Content-length: $size");
               header("Content-type: $type");
               header("Content-Disposition: attachment; filename=$name");
               echo html_entity_decode ($content);}
    exit;
    ?>

    Hi Gun,
    You are the only one responded to my issue. I have allocated some points.
    Yes. I have checked the assignment in CRM organizational model.
    I did download the org. structure from ECC 5.0
    All objects including sales offices are activated for determination and I have verified with green light
    As per your suggestion if the sales area data is not matched between the two systems, then how come the error will not reappear during the bdoc reprocess?
    What is missing during the first time bdoc process? Looks something is missing for validation module?
    Any inputs?
    Thanks,
    Raj

  • How can I use a variable in BEx of type date ?

    Hello,
    I have an infoprovider with a key figure of type "date" and I want to display for example all the data where the date is lower than a date entered by the user.
    So I want to create for that a date variable and use it in conditions.
    When I try with "manual entry", I can't get the type "date" : it proposes quantity, amount, number but not date.
    When I try with "customer exit", I can get the type "date" but when I get it on the selection screen, the date is seen as a number so it doesn't work.
    Does anybody have an idea.
    Thanks for your help.
    Regards,
    Vanessa Roulier

    Hi!
    if you are using a cube then there will be at least one time char. I think you can just add 0calday to your cube , even if you are not filling it.
      Once this is available in cube  it can be used in query (free chars) where we can define a variable on this 0calday. But we it will not have any effect on query results as you are not storing anything in your query.
    then in your conditions you create a variable with USEREXIT type. then in your ABAP code you can access the value stored in variable(which is entered by user) and copy it to the USEREXIT variable. Then your condition works because it is having a date type and the value is date.
    I don't see any problem in implementing this scenario.
    with regards
    ashwin

  • Unix/win problem with sockets

    Hi!
    i have a socket with which i send informations to a tcp/ip client. this works very nice, but on unix, the server sends incorrect data ( makes curious tabs ).
    how can i fix it so sending text with:
    sender = new PrintWriter(sockstream.getOutputStream(), true);
    sender.println("test");
    will works on unix too.
    Thanks
    Chris

    thanks, how can i set this encoding?
    here are two screenshots of this:
    win-server, win client: https://chris86.dyndns.org/pic1.jpg
    unix-server, same client: https://chris86.dyndns.org/pic2.jpg
    thanks :-)
    chris

  • How to set FTP Connection type BINARY with the SOCKET

    hi all,
    manish here.
    could anyone help me in setting the Binary type FTP with the SOCKET.....
    one thing i tried command "TYPE" and argument "I ". but its not accepting and then the Window gets Hang.
    Regards,
    Manish

    X-post:
    http://forum.java.sun.com/thread.jspa?threadID=585104&tstart=0

  • PLEASE:: FTP Connection type BINARY with the SOCKET

    hi all,
    using SOCKET s in the FTP how can i set the Binary mode transfer.
    i tried the "TYPE" command with the frist argument as "I"....but :(
    Please help me.
    Regards,
    manish

    Socket clientSocket = serverSocket.accept();
    Is used when you want to receive data.
    ... after seding the command it Hangs
    Suggenst you want to send data.
    The fact that Socket clientSocket = serverSocket.accept(); is because what this
    command does is wait untill some client sends you a connection request and when
    that happens accept that connection and create a socket for it.
    When you want to send data you don't need a ServerSocket.
    Socket s = new Socket();
    http://javaalmanac.com/cgi-bin/search/find.pl?l=split&words=socket
    I could not find any samples using ftp, I guess the URL object would wrap your
    messages according to the protocol you want to use and is a better candidate for ftp
    than the socket
    http://www.nsftools.com/tips/JavaFtp.htm

  • Panic with Raw Socket-Page fault in module "ip" due to a NULL pointer deref

    I see a panic when using raw sockets with Solaris 10 10/09 (u8). I included a sample program that can cause this issue (panic happens when a udp datagram is received on port 60000). This sample code works as expected with the previous version I was using - 5/08. If I bind with a port number of 0 I don't see the panic but I don't receive anything either.
    I believe I have all the latest patches installed. I'd appreciate any assistance in resolving this. Thanks...
    ^Mpanic[cpu11]/thread=fffffe8000916c60:
    BAD TRAP: type=e (#pf Page fault) rp=fffffe80009166c0 addr=83 occurred in module "ip" due to a NULL pointer dereference
    sched:
    #pf Page fault
    Bad kernel fault at addr=0x83
    pid=0, pc=0xffffffffedf86a10, sp=0xfffffe80009167b0, eflags=0x10246
    cr0: 8005003b<pg,wp,ne,et,ts,mp,pe> cr4: 6f8<xmme,fxsr,pge,mce,pae,pse,de>
    cr2: 83 cr3: 1a345000 cr8: c
    rdi: ffffffffa7092808 rsi: ffffffffb0094e00 rdx: ffffffffa73c9d40
    rcx: 0 r8: fffffe8000916878 r9: fffffe8000916880
    rax: 0 rbx: ffffffffb0094e00 rbp: fffffe8000916800
    r10: ffffffffa7c18840 r11: ffffffffa73c9d40 r12: fffffe8000916880
    r13: ffffffff9b314000 r14: ffffffff9a70b000 r15: 0
    fsb: ffffffff80000000 gsb: ffffffff9c52d800 ds: 43
    es: 43 fs: 0 gs: 1c3
    trp: e err: 0 rip: ffffffffedf86a10
    cs: 28 rfl: 10246 rsp: fffffe80009167b0
    ss: 30
    fffffe80009165d0 unix:die+da ()
    fffffe80009166b0 unix:trap+5e6 ()
    fffffe80009166c0 unix:_cmntrap+140 ()
    fffffe8000916800 ip:ip_udp_check+b0 ()
    fffffe80009168b0 ip:ip_udp_input+15a ()
    fffffe80009169d0 ip:ip_input+c7c ()
    fffffe8000916aa0 dls:i_dls_link_rx+32e ()
    fffffe8000916af0 mac:mac_rx+71 ()
    fffffe8000916b90 bnx:bnx_recv_ring_recv+113 ()
    fffffe8000916ba0 bnx:bnx_rxpkts_intr+17 ()
    fffffe8000916bc0 bnx:bnx_intr_recv+58 ()
    fffffe8000916bf0 bnx:bnx_intr_1lvl+120 ()
    fffffe8000916c40 unix:av_dispatch_autovect+78 ()
    fffffe8000916c50 unix:intr_thread+5f ()
    EXAMPLE USED TO CAUSE ABOVE PANIC
    #include        <unistd.h>
    #include        <stdio.h>
    #include        <stdlib.h>
    #include        <sys/socket.h>
    #include        <arpa/inet.h>
    #define BUFFER_SIZE 2048
    int main(int argc, char *argv[])
            int                     i, j, sd, iosize;
            char                    *ipbuffer;
            struct sockaddr_in      saddr, daddr;
            ipbuffer = calloc( 1, BUFFER_SIZE );
            //if ( ( sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) ) < 0 ) {        // Works
            if ( ( sd = socket(PF_INET, SOCK_RAW, IPPROTO_UDP) ) < 0 ) {            // Fails
                    perror("socket() error");
                    exit(-1);
            saddr.sin_family = AF_INET;
            saddr.sin_addr.s_addr = inet_addr( "0.0.0.0" );
            saddr.sin_port = htons( 60000 );
            if ( bind( sd, (struct sockaddr *) &saddr, sizeof( saddr ) ) < 0 ) {
                    perror("bind() error");
                    exit(-1);
            printf( "Awaiting inbound datagrams...\n" );
            for ( i = 1; i <= 10; i++ ) {
                    j = sizeof( daddr );
                    iosize = recvfrom( sd, ipbuffer, BUFFER_SIZE, 0, (struct sockaddr *) &daddr, &j );
                    printf( "Received %d bytes from %s\n", iosize, inet_ntoa( daddr.sin_addr ) );
            close( sd );
            return( 0 );
    }------------------------------------------------------------------

    This issue could be related. Recommend you open a call with support.
    http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6882984

  • Wierdness with NIO socket on Solaris 2.10 part I

    i tried the following NioClient and MockServer, and saw some weird behavior.
    1. If i run both the client and server on the same machine on Windows, the client connects to the server, queries the instrument and gets the list of instruments back.
    2. if i run both client and server on the same Solaris 2.10 box, the NioClient doesn't get anything back from the MockServer, not even an ACCEPT
    3. if i run the client and the server on different solaris 2.10 machines, they work fine.
    have anyone seen this before? can sometone sheds some lights?
    import java.net.*;
    import java.io.*;
    public class MockServer
         public static int counter = 2;
        public static void main(String[] args) throws IOException {
             int portNumber = Integer.parseInt(args[0]);
            ServerSocket serverSocket = null;
            try {
                serverSocket = new ServerSocket(portNumber);
            } catch (IOException e) {
                System.err.println("Could not listen on port: " + portNumber);
                System.exit(1);
             System.out.println ("Listening on socket " + portNumber);
            do {             
                 Socket clientSocket = null;
                 try {
                     clientSocket = serverSocket.accept();
                     System.out.println ("starting a new client....");
                     MyThread mt = new MyThread (clientSocket);
                     mt.run ();
                 } catch (IOException e) {
                     System.err.println("Accept failed.");
                     System.exit(1);
            while (true);
    class MyThread
         private final Socket clientSocket;
         MyThread (Socket clientSocket)
              this.clientSocket = clientSocket;
         public void run ()
            new Thread (new Runnable () {
                     public void run ()
                          try
                               boolean instrumentquery = false;
                               PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
                               BufferedReader in = new BufferedReader(
                                           new InputStreamReader(
                                           clientSocket.getInputStream()));
                               String inputLine;                          
                               String successoutputLine =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><return><returncode>success</returncode><detail>everything is good</detail></return>";
                               String failoutputLine =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><return><returncode>failure</returncode><detail>something is not good</detail></return>";
                               String instrumentsoutput =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><instruments><instrument><contract>usg-505Y</contract><cusip>12131121</cusip><deactivated>false</deactivated><halted>false</halted></instrument><instrument><contract>usg-305Y</contract><cusip>121312342</cusip><deactivated>false</deactivated><halted>false</halted></instrument></instruments>";
                               while ((inputLine = in.readLine()) != null) {
                                    System.out.println ("Receiving the following" + inputLine);
                                    if (inputLine.contains("queryInstrument")) instrumentquery = true;
                                    if (inputLine.contains("</a>"))
                                         if (instrumentquery)
                                              instrumentquery = false;
                                              System.out.println ("Sending " + instrumentsoutput);
                                              out.println (instrumentsoutput);
                                         else
                                              if ((MockServer.counter % 2) == 0)
                                                   System.out.println ("Sending " + successoutputLine);
                                                   out.println(successoutputLine);
                                              else
                                                   System.out.println ("Sending " + failoutputLine);
                                                   out.println(failoutputLine);
                                              MockServer.counter++;
                               out.close();
                               in.close();
                               clientSocket.close();}
                          catch (Exception ex)
                 }).start (); }
    }please see topic "wierdness with NIO socket on Solaris 2.10 part II" for the NioClient code as the maximum per topic is 5000.

    code for NioClient.java
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.nio.channels.spi.SelectorProvider;
    import java.util.*;
    public class NioClient implements Runnable {
    private InetAddress hostAddress;
    private int port;
    private Selector selector;
    private ByteBuffer readBuffer = ByteBuffer.allocate(8192);
    private List pendingChanges = new LinkedList();
    private Map pendingData = new HashMap();
    private Map rspHandlers = Collections.synchronizedMap(new HashMap());
    public NioClient(InetAddress hostAddress, int port) throws IOException {
    this.hostAddress = hostAddress;
    this.port = port;
    this.selector = this.initSelector();
    public void send(byte[] data, RspHandler handler) throws IOException {
    SocketChannel socket = this.initiateConnection();
    this.rspHandlers.put(socket, handler);
    synchronized (this.pendingData) {
    List queue = (List) this.pendingData.get(socket);
    if (queue == null) {
    queue = new ArrayList();
    this.pendingData.put(socket, queue);
    queue.add(ByteBuffer.wrap(data));
    this.selector.wakeup();
    public void run() {
    while (true) {
    try {
    synchronized (this.pendingChanges) {
    Iterator changes = this.pendingChanges.iterator();
    while (changes.hasNext()) {
    ChangeRequest change = (ChangeRequest) changes.next();
    switch (change.type) {
    case ChangeRequest.CHANGEOPS:
    SelectionKey key = change.socket
    .keyFor(this.selector);
    key.interestOps(change.ops);
    break;
    case ChangeRequest.REGISTER:
    change.socket.register(this.selector, change.ops);
    break;
    this.pendingChanges.clear();
    this.selector.select();
    Iterator selectedKeys = this.selector.selectedKeys().iterator();
    while (selectedKeys.hasNext()) {
    SelectionKey key = (SelectionKey) selectedKeys.next();
    selectedKeys.remove();
    if (!key.isValid()) {
    continue;
    if (key.isConnectable()) {
    this.finishConnection(key);
    } else if (key.isReadable()) {
    this.read(key);
    } else if (key.isWritable()) {
    this.write(key);
    } catch (Exception e) {
    e.printStackTrace();
    private void read(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    this.readBuffer.clear();
    int numRead;
    try {
    numRead = socketChannel.read(this.readBuffer);
    } catch (IOException e) {
    key.cancel();
    socketChannel.close();
    return;
    if (numRead == -1) {
    key.channel().close();
    key.cancel();
    return;
    this.handleResponse(socketChannel, this.readBuffer.array(), numRead);
    private void handleResponse(SocketChannel socketChannel, byte[] data,
    int numRead) throws IOException {
    byte[] rspData = new byte[numRead];
    System.arraycopy(data, 0, rspData, 0, numRead);
    RspHandler handler = (RspHandler) this.rspHandlers.get(socketChannel);
    if (handler.handleResponse(rspData)) {
    socketChannel.close();
    socketChannel.keyFor(this.selector).cancel();
    private void write(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    synchronized (this.pendingData) {
    List queue = (List) this.pendingData.get(socketChannel);
    while (!queue.isEmpty()) {
    ByteBuffer buf = (ByteBuffer) queue.get(0);
    socketChannel.write(buf);
    if (buf.remaining() > 0) {
    break;
    queue.remove(0);
    if (queue.isEmpty()) {
    key.interestOps(SelectionKey.OP_READ);
    private void finishConnection(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    try {
    socketChannel.finishConnect();
    } catch (IOException e) {
    System.out.println(e);
    key.cancel();
    return;
    key.interestOps(SelectionKey.OP_WRITE);
    private SocketChannel initiateConnection() throws IOException {
    SocketChannel socketChannel = SocketChannel.open();
    socketChannel.configureBlocking(false);
    socketChannel
    .connect(new InetSocketAddress(this.hostAddress, this.port));
    synchronized (this.pendingChanges) {
    this.pendingChanges.add(new ChangeRequest(socketChannel,
    ChangeRequest.REGISTER, SelectionKey.OP_CONNECT));
    return socketChannel;
    private Selector initSelector() throws IOException {
    return SelectorProvider.provider().openSelector();
    public static void main(String[] args) {
    try {
    System.out.println ("the host name is " + args[0]);
    NioClient client = new NioClient(
    InetAddress.getByName(args[0]), 4444);
    Thread t = new Thread(client);
    t.setDaemon(true);
    t.start();
    RspHandler handler = new RspHandler();
    client.send(
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><queryInstrument/></a>\n"
    .getBytes(), handler);
    handler.waitForResponse();
    } catch (Exception e) {
    e.printStackTrace();
    }

  • Applet Socketing

    Im trying to make an applet that will connect to a server program.
    I know that the port im using is being forward because i compiled the QuoteServer from the examples and it worked. When I try in an applet it doesnt want to compile.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class QuoteApplet extends Applet {
      DatagramSocket socket;
      DatagramPacket packet;
      InetAddress address;
      byte[] buf;
      String received;
      public void init() {
        socket = new DatagramSocket();
        address = getCodeBase().getHost();
        System.out.println(address);
      public void sendy() {
        // send request
        buf = new byte[256];
        packet = new DatagramPacket(buf, buf.length, address, 4445);
        socket.send(packet);
        packet = new DatagramPacket(buf, buf.length);
        socket.receive(packet);
        received = new String(packet.getData());
        System.out.println("Quote of the Moment: " + received);
        socket.close();
    }Its an adaption of the QuoteClient I know if compiled it will do nothing im trying to make sure that the basic structure works.
    javac -target 1.5 QuoteApplet.java
    QuoteApplet.java:20: incompatible types
    found : java.lang.String
    required: java.net.InetAddress
    address = getCodeBase().getHost();
    ^
    1 error

    Ive used the
    address = getByName("ganbree.no-ip.info");
    it churs out Try Catch errors that ive fixed now.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class QuoteApplet extends Applet {
      DatagramSocket socket;
      DatagramPacket packet;
      InetAddress address;
      byte[] buf;
      String received;
      public void init() {
        try {
          socket = new DatagramSocket();
        } catch(java.net.SocketException e) {
          e.printStackTrace();
        try {
        address = InetAddress.getByName("ganbree.no-ip.info");
        } catch(java.net.UnknownHostException e) {
          e.printStackTrace();
    //    address = InetAddress.getByName(getCodeBase().getHost() );
    //    address = InetAddress.getHostByName(getCodeBase().getHost() );
    //  address = InetAddress.getHostByName("ganbree.no-ip.info");
    //  address = getCodeBase().getHost();
        System.out.println(address);
      public void sendy() {
        // send request
        buf = new byte[256];
        packet = new DatagramPacket(buf, buf.length, address, 4445);
        try {
          socket.send(packet);
        } catch(java.io.IOException e) {
          e.printStackTrace();
        packet = new DatagramPacket(buf, buf.length);
        try {
          socket.receive(packet);
        } catch(java.io.IOException e) {
          e.printStackTrace();
        received = new String(packet.getData());
        System.out.println("Quote of the Moment: " + received);
        socket.close();
    have 2 dollars?

  • Socket with proxy

    guys, I have a raw socket server on a local computer communicating with its client on the same machine. Unfortunately, I can not use Wireshark or Ethereal because they will only works from the local TCP point to the outside world. In my case, all is taken place locally and I want to capture those data between the local raw socket server and its client. I was told that there might be a possibility with using proxy class. Is this possible? If so, could you tell me how?
    btw, there is a really cool software that does what I need:
    http://www.sstinc.com/winsock.html
    Unfortunately, this is only for windows :-), I need a universal solution where I can deploy my tools on any OS. Java is my answer.
    Also, I can not split up the client and raw socket server onto separate machines either so I can use Wireshark. This is the way they're developed.
    Oh another thing, I'd tried creating a java raw socket client which works but I can only attach to one socket port at a time at 1 TCP port. 1 TCP port is fine but I want to be able to sniff every socket ports, capturing every data packets going back and forward between the server and client. I don't know if proxy class works because I don't have a proxy anywhere installed.
    Thanks in advance.

    Something like this. Note I haven't even tried to compile it, it's a 2-minute hack. (You really shouldn't use this directly.)
    class portlogger {
         public static void main(String[] args) throws Exception {
              int source = Integer.parseInt(args[0]); // client's target port
              int target = Integer.parseInt(args[1]);  // server's actual port
              ServerSocket ss = new ServerSocket(source);
              final Socket src = ss.listen();
              final Socket tgt = new Socket("127.0.0.1", target);
              (new Thread(){
                   public void run(){
                        BufferedInputStream br = new BufferedInputStream(src.getInputStream());
                        byte[] buffer = new byte[1024];
                        int bytes;
                        while((bytes = br.read(buffer)) > 0){
                             // log the client's output here, pref. in a threaded way
                             tgt.getOutputStream().write(buffer, 0, bytes);
              }).start();
              (new Thread(){
                   public void run(){
                        BufferedInputStream br = new BufferedInputStream(tgt.getInputStream());
                        byte[] buffer = new byte[1024];
                        int bytes;
                        while((bytes = br.read(buffer)) > 0){
                             // log the server's output here, pref. in a threaded way
                             src.getOutputStream().write(buffer, 0, bytes);
              }).start();
    }

  • Chat Applet - Sockets - Server

    Hello Fellows!
    I hope u all r fine..
    I am facing a problem in my client/sever application. The communication is Socket Based. i.e the server is using sockets and the client which is an Applet, uses sockets to communicate with the sever.
    The application is working fine in the appletviewer. i.e the applet server communication, both can send and recieve messages.
    BUT
    When I use IE5 the client applet can send messages to the sever but is not able to read from the specified socket...
    If Any one can help me out, i will be greatfull. If u need some code segment then let me know.
    Looking forward for any suggestions.
    Thanking You!
    Ahmad.

    Thanks!
    for your contribution....
    but now i realised that the problem is that the client socket thread is not running.
    //////////////////////// Client Applet
    public class Client extends Applet implements ActionListener
    Thread thRead;
    ClientSocket cs;
    private Panel pnlHead = new Panel();
    private Panel pnlMain = new Panel();
    public static Vector vtrMembers;
    public void init()
    thRead = (Thread) new ClientSocket();
         cs = (ClientSocket) thRead;
         vtrMembers = new Vector();
    thRead.start();     
    cs.out.println("INI ? INI");
    ////////////////////////////////////////Client scoket class
    public class ClientSocket extends Thread
    // public static Socket sClient;
    public Socket sClient;
    // A character-input stream to read from the socket.
    public static BufferedReader in;
    // A text-output stream to write to the socket.
    public PrintWriter out ;
    // String to store the input from the client
    String strText;
    // Boolean Flag to Check the read value
    public boolean bFlag = true;
    public ClientSocket ()
         try
         sClient = new Socket ("Ahmed" , 4000);
         // Initializing the Input straem used to read the socket.
    in = new BufferedReader(new InputStreamReader(sClient.getInputStream()));
         // Initializing the Output straem used to write on the socket.
         out = new PrintWriter(sClient.getOutputStream(), true);
         catch (UnknownHostException uhe)
    //     System.out.println (" Unknown Host Exception : " + uhe);
         catch (IOException ioe)
    //     System.out.println (" I/O Exception : " + ioe);
    public void run()
         for (;;)
         if (bFlag == true)
         Client.txtTry.setText("TRUE");
         else
         Client.txtTry.setText("False");
    thRead.start() statment is executed but the thread does not stat running
    because the text value is not set on the Client Applet.

  • Problem with SSL socket(SSLSocketFactoryImpl.createSocket())

    Hello,
    I'm trying to create a ssl socket but I get an exception, I really don't know why. I have alredy include the certificate via keytool to my jdk. And I'm able to get html header with URLConnection with the code below
    import java.net.URL;
    import java.net.URLConnection;
    public class testClass {
         public static void main(String[] args) throws Exception {
              try{
                   URL url = new URL("https://ippbx1:8443/axl/");
                   String userPassword = "****" + ":" + "****";
                   String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
                   URLConnection c = url.openConnection();
                   c.setRequestProperty("Authorization", "Basic " + encoding);
                   for (int i=0; ; i++)
                        String name = c.getHeaderFieldKey(i);
                        String value = c.getHeaderField(i);
                        if (name == null && value == null)     // end of headers
                             break;        
                        if (name == null)     // first line of headers
                             System.out.println("Server HTTP version, Response code:");
                             System.out.println(value);
                             System.out.print("\n");
                        else
                             System.out.println(name + "=" + value);
              catch (Exception e) {}
    }and I get the following result :
    Server HTTP version, Response code:
    HTTP/1.1 200 OK
    Server=Apache-Coyote/1.1
    Pragma=No-cache
    Cache-Control=no-cache
    Expires=Thu, 01 Jan 1970 01:00:00 CET
    Set-Cookie=JSESSIONIDSSO=77670D5480DAD295C6519E812F9FED64; Path=/
    Set-Cookie=JSESSIONID=B71BDB730FA5B3B431D3B16C41E190E3; Path=/axl; Secure
    Content-Type=text/html;charset=ISO-8859-1
    Content-Length=233
    Date=Wed, 10 Jun 2009 15:17:10 GMTBut when I try to make a socket :
    import java.io.*;
    import java.net.*;
    import javax.net.SocketFactory;
    import javax.net.ssl.SSLSocketFactory;
    public class axlforward {
         public static void main(String[] args) {
    String address = "https://ippbx1:8443/axl/";        
              int portnum = 8443;
    try
                   SocketFactory socketFactory = SSLSocketFactory.getDefault();
                   Socket socket = socketFactory.createSocket(address, portnum);
    } catch (Exception e) {e.printStackTrace();} I get the following
    java.net.UnknownHostException: https://ippbx1/axl/
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:519)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:353)
         at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
         at axlforward.main(axlforward.java:89)I have a VB program that connects to the socket(with Inet1.Protocol = icHTTPS and Inet1.Execute strURL, "Post", strFormData, strFormHdr methods) and do what I want but I need to do it in Java but I'm not able to find the error.
    the server socket is a Cisco callManager Service(AXL Web Service) which receives and html+SOAP request and sends back an xml response and this server socket is running correctly with no problem.
    Thanks for your help.

    Jdevelopper8709 wrote:
    Thanks for your reply.
    I now can access to my socket and get the information I want with:
    SocketFactory socketFactory = SSLSocketFactory.getDefault();
                   socket = (SSLSocket) socketFactory.createSocket("ippbx1", 8443);In fact the problem was a username/password issue.
    Thanks.I quote from reply #1 "The address is just "ippbx1" and not "https://ippbx1:8443/axl/". The protocol is not part of the IP address.".

Maybe you are looking for

  • Use of NVL, Is it correct or wrong

    Hi, I've doubt regarding the use of NVL in SQL query, Eg. for query : SELECT * FROM NBS_POLICY_MST WHERE ORG_POLICY_ID = NVL(:p1,ORG_POLICY_ID); PLAN_TABLE_OUTPUT | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| | 0 | SELECT STATEMENT | | 2084 |

  • Tips and Tricks-how 2

    I was looking for any place where I could get answers on how to make my ipod do the things that I know it can. For example on more than a couple of occasions I have managed to turn off the video but leave the sound by holding down the play pause butt

  • Cross tab Date Column Grouping

    Hi, I have a cross tab in my report which displays no of tickets opened grouped by day, week or Month, grouping is done based on a parameter GroupBy, which has Day, Week, Month values Incident   Jun -99  Jul-99 Priority1      10          20 Priority2

  • How do I set up an MS Stereo Pair in Logic 7?

    So we are now dabbling into the MS Stereo pair for our recording tech class and I can't seem to find an easy way of doing this. Any suggestions? I can't find a real time phase inversion plug-in or button anywhere other than going through the wave edi

  • After updating to IOS6 version of iTunes my ATV2 is very slow?

    Pre update everything was fine but now it constantly tries "loading themoffsters library" Anyone else had this issue? I've restarted and rebooted the ATV2 and nothing else. Hanged overnight.