Looking fo a basic TCP client

Hi,
after I managed to learn a little more from scratch about networking (thanks for those who argued with me about that ), I am now looking for a higher level class for a TCP communication (which is indeed a response to this previous discussion).
The important features are :
- It must be threaded so that the "listening" process do not block the programm.
- It must have callbacks (which is quite the same as the previous point)
- It must accept "connected" communication
- It must be basic : I don't want to use netservices for example. I juste want to "connect" to a foreign server (according to its IP), and then exchange bytes (I will manage incoming data on my own). Since I don't know what the server will be, data must be as basic as possible.
- No archieving, XML, or any other automatic data formating, including automatic byte swapping : I want to perform it on my own.
- Other expected features are usual ones : safe, light, etc...
I already experimented some like Drew McCormack's one... but this one for example did Archieve a NSData and assumed that the Server could deal with it.
Then... my question (finally!) is : do you know of such a class / lib / framework, ready to use, that I could use?
The client app is developed on an iPhone, but I assume such classes can be deployed on both MacOs an iPhoneOS (but I'd rather specify it in case it could not be).

g_Marvin wrote:
Please to argue with you again
You'll have to refresh my memory. Sorry if I am therefore repeating myself.
Why? : because I assumed I needed those features for a non blocking process.
To clarify a couple of things, you only really use the term "blocking" when referring to I/O. Usually, "blocking" is used when talking about low-level, filesystem I/O. Modern networking code is designed so that you need only do the minimum of "non-blocking" work. You set one socket, the listening socket, to be non-blocking. Then, you run the multiplexor function, select(), using any open file descriptors. The select() function will tell you which of your open file descriptors has any activity. Then, you use the easier "blocking" functions with the assurance that they will not block because there is already data available.
My app will perform some various tasks (such as responding to user actions and compute many data), but must switch to the processing of incoming bytes as soon as needed.
You can handle user action and networking without multithreading. If you have some intensive processing, it would be much easier to move said processing into another thread and keep the I/O in the main thread. Do you need to "process" the incoming bytes as soon as possible, or just read them from the input stream? It is pretty easy to setup a producer-consumer model with a worker thread to process data in the worker thread after you have read the data in the main thread.
It must also be able to handle disconnection from server without blocking the main process (through a "callback")
This usually isn't a problem and doesn't require a callback.
TCP : yes. I know it is "connected". I prefer some things to be said twice (since I happen to miss the first one myself)
You could also use UDP, if you own both sides of the conversation.
"Basic" : I meant something with basic features : no "special" features such as archieving, XML encapsuling, preliminar broadcasting, etc (especially if automatic). Only sockets and some callbacks (don't know if I use the suiting word here). From our previous conversation and my personnal (and recent) experience, I know that this is not a basic thing.
It is pretty basic. Unfortunately, it appears harder from C and C++ than it really needs to be. It might be a good idea to play around with Perl first. You can see how all the network code is supposed to work without getting bogged down in the details.
C Sockets I already tried (according to my previous question you also helped about). This works but is not safe at all (many runtime errors).
It should be perfectly safe if you do proper error handling. But I agree that said error handling can be complex.
NSFileHandle : didn't know it at all... but it looked very attractive. I am having a look at it.
NSStream and CFNetwork : I suppose they are to be used together.
Not necessarily. They are both wrappers around the C code, as is NSFileHandle.

Similar Messages

  • 11.2.0.3.20 "Basic Lite" Client?

    Cross posting from
    Re: No "Lite" version of 11.2.0.3.20 ODAC?
    on orafad's recommendation (thanks!)
    Is there a "basic lite" instant client that corresponds to ODAC 11.2.0.3.20?
    I'm assuming it's needed because we're building / deploying on .net 4.5 which is only supported in ODAC 11.2.0.3.20?
    I'm mainly looking for the oraociicus11.dll that has limited character sets -- which is about 34 MB -- I don't want to have to ship 125+ meg version unless we absolutely need to.
    from orafad's response to my questions -- if it helps to translate to oracle speak :) --
    The last .20 is a patch version. Which means it may be that Instant Client was not patched, only some other dlls, and therefor 11.2.0.3 is the latest available.
    (Note that individual dll versions may differ from patch version.)
    The only a few client character sets - version you are looking for is Basic Lite. And yes name of package matters in this case
    I assumes you meant: oraociicus11.dll, which is about 34 MB.
    Forum dedicated to Instant Client, to which this thread belongs, Instant Client
    Regards, Chad

    Looking at
    http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html
    I see that "ODAC 11.2 Release 5 (11.2.0.3.20)" includes "Oracle Instant Client 11.2.0.3.0".
    11.2.0.3.20 seems to only apply to "Oracle Developer Tools for Visual Studio".
    So unless Oracle is quite sloppy about their version numbers (which they usually are not)
    that would be exactly the same version as the download from
    http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
    So I would feel safe about removing oraociei11.dll and replacing it with oraociicus11.dl
    from Instant Client Basic Lite 10.2.0.3.0.
    Also, the Instant Client shared library contains message and time zone files, and the chances
    that these change between fixpacks is not so big.
    Of course, if you need certainty that this is supported, you'd have to have support and
    open a service request.
    Yours,
    Laurenz Albe

  • TCP client server sample

    All,
    This may not really be a LabWindows/CVI question but I'm really stuck on what should be easy to
    solve. The brain trust here on the forums has always been helpful so I'll try to explain.
    The project:
    Get LabWindows/CVI code talking to a muRata SN8200 embedded WiFi module.
    The setup:
    (running Labwindows/CVI 2009)
    Computer 1 -- (with a wireless NiC) running simple demo TCP server program provided by muRata.
    Computer 2 -- USB connection (virtual COM port) with simple program (also provided by muRata) that talks to the SN8200 embedded WiFi module.  This code along with the module creates a simple TCP client.
    Whats working:
    I can successfuly get the Computer 2 client connected to and talking to the Computer 1 server. (using the muRata supplied code)
    I can also run the LabWindows/CVI sample code from (\CVI2009\samples\tcp), server on computer 1 & client on computer 2 and they talk with no problems.
    (I'm using the same IP addresses and port numbers in all cases)
    Whats NOT working:
    Run the CVI server program on computer 1.
    I cannot get the muRata client program  to connect to the CVI server.
    I also tried get the CVI client program to connect to the muRata server.  No luck that way either. The CVI client sample program trys connect, and this function call:
    ConnectToTCPServer (&g_hconversation, portNum, tempBuf, ClientTCPCB, NULL, 5000 );
    returns with a timeout error code (-11).
    What I need:
    Some ideas on how to get this working.
    Is there something unique about the LabWindows/CVI sample client/server demo code that would make them incompatible with the muRata code?
    Can you think of some ways I can debug this further?  I feel like I'm kind of running blind.
    What else can I look at?
    For those that have read this far, thanks much and any ideas or comments will be appreciated,
    Kirk

    Humphrey,
    First,
    I just figured out what the problem is:
    When I was trying to use the CVI sample server I was entering the wrong port number.
    The reason I entered the wrong port was because the hard-coded port number in the muRata demo code was displayed in hex as 0x9069. ( I converted this to decimal and entered it into the CVI sample server code) The correct port number was 0x6990.  (upper and lower bytes swapped)  Arrgh!
    I found the problem by using the netstat command line utility to display the connections and noted that the port being used was not 0x9069.  It is really a problem with the muRata eval kit demo code.
    Second,
    Humphrey you are right about the CVI sample code not handling all the muRata commands for the client end of the connection that communicates with the SN8200 module.  For my test I was using the muRata code for that "end".
    The server end is simple and the CVI sample is adequate and is now working.
    Thank you to all who took the time to browse my questions,
    Kirk

  • TCP client communicating with UDP server

    Hello,
    I want to make a TCP client to communicate with an UDP server. Does anyone know a way of doing this? I am not interested in reliable data transfer. So I don't care if the datagram is lost. I want to make the UDP server accept some datagrams from the TCP client. Also, the datagram that I want to transmit is less than 65,536 octets so it is not devided to several datagrams. Therefore, only one exchange procedure occurs.
    I made an UDP server using DatagramSocket and DatagramPacket classes and a TCP client using Socket class, but the TCP client informs me that the connection was refused.
    Any ideas?

    Let's google for IP header and the first hit is http://www.networksorcery.com/enp/protocol/ip.htm (Whoa! Classic page! I must have seen that back when googling was called altavista.)
    There is a header field, a single byte, called protocol. For TCP/IP that field contains 6, for UDP/IP it contains 17.
    If you send a packet with protocol=17, the receiving host's kernel will check if it has an process listening to UDP (17) at the port specified in the packet header. No such process? Then simply discard the packet. So you can't send an UDP packet to a TCP socket because the protocol field is wrong.
    If you want to fake a TCP stream you could look into jpcap, which allows you to capture and send raw packets. Google for it; and pick the right jpcap, there are two, only one of which (AFAIK) can send packets. Attempting to write your own TCP implementation is highly advanced though, and not really practical.

  • TCP Client - Server Prog.

    Hi All,
    I have posted TCP client- server prog. I have trouble in client code. When i'm running the server code on some port and the running the client code on the same port, then client is sending message to server(in this case integers with space like 12 22 23) , the server is receiving the message and adding the sum and sending the sum to client, but when i'm trying to read the stream from server(i.e the sum), i'm getting nothing.........
    please run the code and check.......u can understand well....
    please reply me as soon as possible.
    Thanks
    import java.io.*;
    import java.net.*;
    class TCPAdditionClient
         public static void main(String args[]) throws Exception
         {   Character ans = null;
              String hostname="localhost";
              String sentence;
              String result;
              int port=0;
              if (args.length > 0) {
              try {
              port = Integer.parseInt(args[0]);
              } catch (NumberFormatException e) {
              System.err.println("Argument must be an integer");
              System.exit(1);
              Socket clientSocket = new Socket(hostname,port);
              do
                   System.out.println("Enter the number of integers....");
                   BufferedReader fromUser = new BufferedReader(new InputStreamReader(System.in));
                   sentence = fromUser.readLine();
                   DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
                   //System.in.read();
                   outToServer.writeBytes(sentence + '\n');
                   System.out.println("server sends message");
                   BufferedReader fromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                   System.out.println(fromServer);
                   result = fromServer.readLine();
                   System.out.println("from Server" + result);
                   System.out.println("Do u want to continue y/n");
              }while(! ans.equals("n"));
              clientSocket.close();
    import java.io.*;
    import java.util.*;
    import java.net.*;
    class TCPAdditionServer
         public static void main(String args[]) throws Exception
              String clientSentence;
              int port=0;
              if (args.length > 0) {
              try {
              port = Integer.parseInt(args[0]);
              } catch (NumberFormatException e) {
              System.err.println("Argument must be an integer");
              System.exit(1);
              ServerSocket welcomeSocket = new ServerSocket(port);
              while(true)
                   int sum = 0,total_sum = 0;
                   Socket connectionSocket = welcomeSocket.accept();
                   BufferedReader fromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
                   DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
                   clientSentence = fromClient.readLine();
                   System.out.println(clientSentence);
                   String[] result = clientSentence.split(" ");
                   for (int x=0; x<result.length; x++)
                        sum = Integer.parseInt(result[x]);
                        total_sum = sum + total_sum;
                        System.out.println(total_sum);
                   String sendData = "from the server" + "sum :" + total_sum;
                   System.out.println(sendData);
                   outToClient.writeBytes(sendData);
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    can u explain it http://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal - in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • Async tcp client and server. How can I determine that the client or the server is no longer available?

    Hello. I would like to write async tcp client and server. I wrote this code but a have a problem, when I call the disconnect method on client or stop method on server. I can't identify that the client or the server is no longer connected.
    I thought I will get an exception if the client or the server is not available but this is not happening.
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    How can I determine that the client or the server is no longer available?
    Server
    public class Server
    private readonly Dictionary<IPEndPoint, TcpClient> clients = new Dictionary<IPEndPoint, TcpClient>();
    private readonly List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
    private TcpListener tcpListener;
    private bool isStarted;
    public event Action<string> NewMessage;
    public async Task Start(int port)
    this.tcpListener = TcpListener.Create(port);
    this.tcpListener.Start();
    this.isStarted = true;
    while (this.isStarted)
    var tcpClient = await this.tcpListener.AcceptTcpClientAsync();
    var cts = new CancellationTokenSource();
    this.cancellationTokens.Add(cts);
    await Task.Factory.StartNew(() => this.Process(cts.Token, tcpClient), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
    public void Stop()
    this.isStarted = false;
    foreach (var cancellationTokenSource in this.cancellationTokens)
    cancellationTokenSource.Cancel();
    foreach (var tcpClient in this.clients.Values)
    tcpClient.GetStream().Close();
    tcpClient.Close();
    this.clients.Clear();
    public async Task SendMessage(string message, IPEndPoint endPoint)
    try
    var tcpClient = this.clients[endPoint];
    await this.Send(tcpClient.GetStream(), Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async Task Process(CancellationToken cancellationToken, TcpClient tcpClient)
    try
    var stream = tcpClient.GetStream();
    this.clients.Add((IPEndPoint)tcpClient.Client.RemoteEndPoint, tcpClient);
    while (!cancellationToken.IsCancellationRequested)
    var data = await this.Receive(stream);
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(NetworkStream stream, byte[] buf)
    await stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive(NetworkStream stream)
    var lengthBytes = new byte[4];
    await stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await stream.ReadAsync(buf, 0, buf.Length);
    return buf;
    Client
    public class Client
    private TcpClient tcpClient;
    private NetworkStream stream;
    public event Action<string> NewMessage;
    public async void Connect(string host, int port)
    try
    this.tcpClient = new TcpClient();
    await this.tcpClient.ConnectAsync(host, port);
    this.stream = this.tcpClient.GetStream();
    this.Process();
    catch (Exception exception)
    public void Disconnect()
    try
    this.stream.Close();
    this.tcpClient.Close();
    catch (Exception exception)
    public async void SendMessage(string message)
    try
    await this.Send(Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(byte[] buf)
    await this.stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await this.stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive()
    var lengthBytes = new byte[4];
    await this.stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await this.stream.ReadAsync(buf, 0, buf.Length);
    return buf;

    Hi,
    Have you debug these two applications? Does it go into the catch exception block when you close the client or the server?
    According to my test, it will throw an exception when the client or the server is closed, just log the exception message in the catch block and then you'll get it:
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.Invoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    Console.WriteLine(exception.Message);
    Unable to read data from the transport connection: An existing   connection was forcibly closed by the remote host.
    By the way, I don't know what the SafeInvoke method is, it may be an extension method, right? I used Invoke instead to test it.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do you configure the RTC as an Extend/TCP client vs Compute Client?

    How do you choose between the Real Time Client acting as an Extend/TCP Client or a Compute Client?
    Thanks,
    Andrew

    Hi Andrew,
    I believe RT client as a Compute client means storage-disabled normal TCMP cluster node in a Grid Edition cluster, but I may be wrong.
    Best regards,
    Robert

  • What is the best program for designing event flyers? I am looking for something basic and simple.

    What is the best program for designing event flyers? I am looking for something basic and simple.

    Poor old Photoshop® is forever being put down when it comes to layout work, but it is perfectly capable, and can output a high quality print PDF the printer will be perfectly happy with.  OK you don't have the text flow between columns bells and whistles of InDesign and [spit] Publisher, but if you have a $10/month Photoshop/Lightroom subscription, instead of the $50/month full subscription, don't think you can't do a perfectly good flyer or poster.
    https://helpx.adobe.com/photoshop/how-to/align-objects-guides.html

  • Handle Received data of Multiple TCP clients on TCP Server by displaying them into Datagrid

    Hello All,
    I have developed a C# based TCP server GUI application which is accepting the data from multiple TCP clients on TCP server.
    The data i am receiving from TCP clients is a 32 bit data. In my application multiple TCP client data goes like this:
    00012331100025123000124510321562
    01112563110002512456012451032125 and so on...
    Now i want those data of the TCP clients to be parsed into 4 bits first and display it in 8 columns (32/4=8) of (say) datagrid as each 4 bit represents some characteristics of the TCP client. The same thing
    should work for next TCP client on second row of datagrid.            
    Can you give me some suggestion or an example how to go about this? Any help would be appreciated.
     Thank you in advance.
    Here is my code for receiving data from multiple TCP clients.
    void m_Terminal_MessageRecived(Socket socket, byte[] buffer)
    string message = ConvertBytesToString(buffer, buffer.Length);
    PublishMessage(listMessages, string.Format("Sockets: {0}", message));
    // Send Echo
    // m_ServerTerminal.DistributeMessage(buffer);
    private string ConvertBytesToString(byte[] bytes, int iRx)
    char[] chars = new char[iRx + 1];
    System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
    d.GetChars(bytes, 0, iRx, chars, 0);
    string szData = new string(chars);
    return szData;

    Now i want those data of the TCP clients to be parsed into 4 bits first and display it in 8 columns (32/4=8) of (say) datagrid as each 4 bit represents some characteristics of the TCP client. The same thing
    should work for next TCP client on second row of datagrid
    If mean it's a Windows Forms application and you want to display those bits in a DataGridView control, then please see these threads:
    Add row to datagridview
    Programmatically add new row to DataGridView
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Help with MIDlets - TCP client server program

    Hi I am new to using MIDlets, and I wanted to create a simple TCP client server program.. I found a tutorial in J2me forums and I am able to send a single message from server(PC) to client(Phonemulator) and from client to server. But I want to send a stream of messages to the server. Here is my program and I am stuck in the last step wher i want to send lot of messages to server. Here is my program, Could any one of u tell me how to do it? Or where am i going wrong in thsi pgm?
    Code:
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.SocketConnection;
    import javax.microedition.io.StreamConnection;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeExcepti on;
    public class SocketMIDlet extends MIDlet
    implements CommandListener, Runnable {
    private Display display;
    private Form addressForm;
    private Form connectForm;
    private Form displayForm;
    private TextField serverName;
    private TextField serverPort;
    private StringItem messageLabel;
    private StringItem errorLabel;
    private Command okCommand;
    private Command exitCommand;
    private Command backCommand;
    protected void startApp() throws MIDletStateChangeException {
    if (display == null) {
    initialize();
    display.setCurrent(addressForm);
    protected void pauseApp() {
    protected void destroyApp(boolean unconditional)
    throws MIDletStateChangeException {
    public void commandAction(Command cmd, Displayable d) {
    if (cmd == okCommand) {
    Thread t = new Thread(this);
    t.start();
    display.setCurrent(connectForm);
    } else if (cmd == backCommand) {
    display.setCurrent(addressForm);
    } else if (cmd == exitCommand) {
    try {
    destroyApp(true);
    } catch (MIDletStateChangeException ex) {
    notifyDestroyed();
    public void run() {
    InputStream is = null;
    OutputStream os = null;
    StreamConnection socket = null;
    try {
    String server = serverName.getString();
    String port = serverPort.getString();
    String name = "socket://" + server + ":" + port;
    socket = (StreamConnection)Connector.open(name, Connector.READ_WRITE);
    } catch (Exception ex) {
    Alert alert = new Alert("Invalid Address",
    "The supplied address is invalid\n" +
    "Please correct it and try again.", null,
    AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    display.setCurrent(alert, addressForm);
    return;
    try {
    // Send a message to the server
    String request = "Hello\n\n";
    //StringBuffer b = new StringBuffer();
    os = socket.openOutputStream();
    //for (int i=0;i<10;i++)
    os.write(request.getBytes());
    os.close();
    // Read the server's reply, up to a maximum
    // of 128 bytes.
    is = socket.openInputStream();
    final int MAX_LENGTH = 128;
    byte[] buf = new byte[MAX_LENGTH];
    int total = 0;
    while (total<=5)
    int count = is.read(buf, total, MAX_LENGTH - total);
    if (count < 0)
    break;
    total += count;
    is.close();
    String reply = new String(buf, 0, total);
    messageLabel.setText(reply);
    socket.close();
    display.setCurrent(displayForm);
    } catch (IOException ex) {
    Alert alert = new Alert("I/O Error",
    "An error occurred while communicating with the server.",
    null, AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    display.setCurrent(alert, addressForm);
    return;
    } finally {
    // Close open streams and the socket
    try {
    if (is != null) {
    is.close();
    is = null;
    } catch (IOException ex1) {
    try {
    if (os != null) {
    os.close();
    os = null;
    } catch (IOException ex1) {
    try {
    if (socket != null) {
    socket.close();
    socket = null;
    } catch (IOException ex1) {
    private void initialize() {
    display = Display.getDisplay(this);
    // Commands
    exitCommand = new Command("Exit", Command.EXIT, 0);
    okCommand = new Command("OK", Command.OK, 0);
    backCommand = new Command("Back", Command.BACK, 0);
    // The address form
    addressForm = new Form("Socket Client");
    serverName = new TextField("Server name:", "", 256, TextField.ANY);
    serverPort = new TextField("Server port:", "", 8, TextField.NUMERIC);
    addressForm.append(serverName);
    addressForm.append(serverPort);
    addressForm.addCommand(okCommand);
    addressForm.addCommand(exitCommand);
    addressForm.setCommandListener(this);
    // The connect form
    connectForm = new Form("Connecting");
    messageLabel = new StringItem(null, "Connecting...\nPlease wait.");
    connectForm.append(messageLabel);
    connectForm.addCommand(backCommand);
    connectForm.setCommandListener(this);
    // The display form
    displayForm = new Form("Server Reply");
    messageLabel = new StringItem(null, null);
    displayForm.append(messageLabel);
    displayForm.addCommand(backCommand);
    displayForm.setCommandListener(this);

    Hello all,
    I was wondering if someone found a solution to this..I would really appreciate it if u could post one...Thanks a lot..Cheerz

  • Extend TCP- clients Failover

    Hi,
    In an attempt to failover a TCP client we had the following config file which setup with the following elements
                   <heartbeat-interval>50s</heartbeat-interval>
                   <heartbeat-timeout>35s</heartbeat-timeout>
    When inserting the event handler for the service stopping with the following code
    public static void InstallServiceEventHandler(string servicename, ServiceEventHandler eh) //this should be a generic handler in
    Tangosol.Net.IService ics = CacheFactory.GetService(servicename); -->This line throws
    try{
    ics.ServiceStopping += eh;
    catch (Exception e)
    log.Error("Exception in the service Event handler insertion", e);
    return;
    The Exception is
    {"The element 'outgoing-message-handler' in namespace 'http://schemas.tangosol.com/cache' has *invalid* child element 'heartbeat-interval' in namespace 'http://schemas.tangosol.com/cache'."}
    On commenting out the hearbeat* lines the above line executes....Which is of course useless to detect Server failures without a heartbeat.
    What are we doing wrong?
    Thanks,
    Vipin
    Given below is the
    <cache-config xmlns="http://schemas.tangosol.com/cache">
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>dist-*</cache-name>
    <scheme-name>extend-direct</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <remote-cache-scheme>
    <scheme-name>extend-direct</scheme-name>
    <service-name>ExtendTcpCacheService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
              <socket-address>
    <address>nycs00057388.us.net.intra</address>
    <port>8078</port>
    </socket-address>
                   <socket-address>
                        <address>nycs00057389.us.net.intra</address>
                        <port>8078</port>
                   </socket-address>
              </remote-addresses>
    </tcp-initiator>
    <outgoing-message-handler>
    <request-timeout>30s</request-timeout>
                   <heartbeat-interval>50s</heartbeat-interval>
                   <heartbeat-timeout>35s</heartbeat-timeout>
              </outgoing-message-handler>
    </initiator-config>
    </remote-cache-scheme>
    <remote-invocation-scheme>
    <scheme-name>extend-invocation</scheme-name>
    <service-name>ExtendTcpInvocationService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
    <socket-address>
    <address>nycs00057388.us.net.intra</address>
    <port>8078</port>
    </socket-address>
    </remote-addresses>
    </tcp-initiator>
    <outgoing-message-handler>
    <!--<request-timeout>30s</request-timeout>-->
    </outgoing-message-handler>
    </initiator-config>
    </remote-invocation-scheme>
    </caching-schemes>
    </cache-config>

    Hi Vipin -
    While I do not have a definite answer on the issue, the internal tracking number is COH-2534. While I cannot commit on dates, at last check it was being worked on for inclusion in 3.6, and the fix would likely be back-ported to 3.5.x.
    I suggest that you open an SR with Oracle Support if you have not already done so, so that you can specifically request the resolution of this and the backport to 3.5.
    I apologize for the inconvenience that this has caused you.
    Peace,
    Cameron Purdy | Oracle Coherence

  • TCP Client/Server Whiteboard - Like Netmeeting - Need advice

    I won't get into details of the full project, but one part of the project is a whiteboard-like VI that works similar to the whiteboard in Netmeeting. I created a quick server and client VI to establish a TCP connection to allow the whiteboard to run for everyone. Run the server VI first and then the client VI and the whiteboards will open. Normally you would only have one whiteboard running, but this is a demo to allow the client and server to run on the same computer. Please execute the project to understand what the program does so that you understand the concept.
    Now for my problem: I spent a several days designing this portion of my project and it is fairly usable, but the problem is that if you continuously draw on the screen for a long time (maybe 1 minute), the arrays will get rather large and will eventually slow the drawing process to a crawl. In a previous version I would draw to the screen, feedback the picture element, and then clear the array, thinking this would be the most efficient. Unfortunately it seemed to be pretty slow also.
    I've only been using Labview for a year, so please forgive me if my code is sloppy or if I did things in a weird way. This is why I am posting this code. I'm really looking for advice on optimizing the code and fixing my main problem.
    Attachments:
    Whiteboard.zip ‏413 KB

    Hi Travis,
    Thanks for your reply. I saw your post after I already solved the problem otherwise I would look into your suggestions. I thought I would post the solution here so that this code might help someone in the future.
    To recap, I had a problem with a drawing slowdown using two different methods. The first method was to draw to a picture element and then loop this around the main while loop and then draw to the picture element again for every pixel movement captured. Reloading the picture element rapidly was a major drag on the CPU. So the second method I used was to store all pixels movements captured in an array and add another array to the second dimension every time the mouse button lifted. I would draw EVERYTHING in this 2D array everytime I looped around. This meant that the array could get rather large after a very short time and bog down the CPU.
    So I realized that I could take the best of both methods mentioned and use a nested while loop inside another while loop. The outer while loop shifts the picture element around and the inner loop will continue to build and redraw only one row of the array until the mouse button is up. At this point I stop the inner loop and pass the picture element around null the arrays for the inner loop. Seems to accomplish everything I needed.
    Hope this can help somebody else. The new code is attached
    Attachments:
    Whiteboard.zip ‏515 KB

  • Looking for app to manage client list

    I'm looking for an app/software that can manage scheduling, inventory, client formulas, client photos, client history, using Mac Address Book. I want to add/access this information using my macbook pro, i pad mini, and iphone. I understand Bento has changed and no longer interfaces with mac address book. Anyone have any other suggestions?

    Do a Google, Bing, Macupdate & CNET Mac Download search. 

  • Looking for some basics/fundamentals of XML Parsing in ABAP

    Hello SAP gurus
    I have to start workign on a project that involves Variant Configuration stuff that will be sent as XML document. I have to parse the XML document and save the needed data in some custom tables. I heard that there are some standard functions that we can use to do this job. I tried searching SDN for string XML parsing and got tons of postings regarding this. I tried to go through them one by one but it was way beyond my understanding at this time. I am looking for the fundamentals or how to start from scratch.
    I would appreciate if anybody can guide me to find some kind tutorial or basic info on where and how to start.
    Thanks a lot in advance
    Ram

    XML parsing through CALL TRANSFORMATION is one of the easiest method. A transformation needs to be created as per your XML data in transaction XSLT_TOOL and the transformation needs to be called in ABAP program using "CALL TRANSFORMATION" statement.
    Kindly search in internet for XSLT/simple transformations.

  • Extend-TCP client not failing over to another proxy after machine failure

    I have a configuration of three hosts. on A is the client, on B & C are a proxy and a cache instance. I've defined an AddressProvider that returns the address of B and then C. The client just repeatedly calls the cache (read-only). The client configuration is:
    <?xml version="1.0"?>
    <cache-config
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
    xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config
    coherence-cache-config.xsd">
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>cache1</cache-name>
    <scheme-name>extend-near</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <!-- Use ExtendTCP to connect to a proxy. -->
    <caching-schemes>
    <near-scheme>
    <scheme-name>extend-near</scheme-name>
    <front-scheme>
    <local-scheme>
    <high-units>1000</high-units>
    </local-scheme>
    </front-scheme>
    <back-scheme>
    <remote-cache-scheme>
    <scheme-ref>remote-cache1</scheme-ref>
    </remote-cache-scheme>
    </back-scheme>
    <invalidation-strategy>all</invalidation-strategy>
    </near-scheme>
    <remote-cache-scheme>
    <scheme-name>remote-cache1</scheme-name>
    <service-name>cache1ExtendedTcpProxyService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
    <address-provider>
    <class-name>com.foo.clients.Cache1AddressProvider</class-name>
    </address-provider>
    </remote-addresses>
    <connect-timeout>10s</connect-timeout>
    </tcp-initiator>
    <outgoing-message-handler>
    <request-timeout>5s</request-timeout>
    </outgoing-message-handler>
    </initiator-config>
    </remote-cache-scheme>
    </caching-schemes>
    If I shutdown the proxy that the client is connected to on host B, failover occurs quickly by calling the AddressProvider. But if I shut down the network for host B (or drop the TCP port of the proxy on B) to simulate a machine failure, failover does not occur. The client simply continues to try to contact B and dutifully times out in 5 seconds. It never asks the AddressProvider for another address.
    How do I get failover to kick in?

    Hello,
    If you are testing Coherence*Extend failover in the face of a network, machine, or NIC failure, you should enable Connection heartbeats on both the <tcp-initiator/> and <tcp-acceptor/>. For example:
    Client cache config:
    <remote-cache-scheme>
      <scheme-name>extend-direct</scheme-name>
      <service-name>ExtendTcpCacheService</service-name>
      <initiator-config>
        <tcp-initiator>
          <remote-addresses>
            <socket-address>
              <address system-property="tangosol.coherence.extend.address">localhost</address>
              <port system-property="tangosol.coherence.extend.port">9099</port>
            </socket-address>
          </remote-addresses>
          <connect-timeout>2s</connect-timeout>
        </tcp-initiator>
        <outgoing-message-handler>
          <heartbeat-interval>10s</heartbeat-interval>
          <heartbeat-timeout>5s</heartbeat-timeout>
          <request-timeout>15s</request-timeout>
        </outgoing-message-handler>
      </initiator-config>
    </remote-cache-scheme>Proxy cache config:
    <proxy-scheme>
      <scheme-name>example-proxy</scheme-name>
      <service-name>ExtendTcpProxyService</service-name>
      <thread-count system-property="tangosol.coherence.extend.threads">2</thread-count>
      <acceptor-config>
        <tcp-acceptor>
          <local-address>
            <address system-property="tangosol.coherence.extend.address">localhost</address>
            <port system-property="tangosol.coherence.extend.port">9099</port>
          </local-address>
        </tcp-acceptor>
        <outgoing-message-handler>
          <heartbeat-interval>10s</heartbeat-interval>
          <heartbeat-timeout>5s</heartbeat-timeout>
          <request-timeout>15s</request-timeout>
        </outgoing-message-handler>
      </acceptor-config>
      <autostart system-property="tangosol.coherence.extend.enabled">true</autostart>
    </proxy-scheme>This is because it may take the TCP/IP stack a considerable amount of time to detect that it's peer is unavailable after a network, machine, or NIC failure (O/S dependent).
    Jason

Maybe you are looking for

  • How to compare consecutive groups of numbers in arrays

    Hi I require to place the solution into a 1D array. I need to compare two arrays and save the same numbers that are in both arrays but also save groups of numbers that may be in only one of the two arrays being compared. In the example l have not bee

  • Wifi on ipad 2

    Is there something that will extend the reach of my wifi on ipad 2?  I didn't get it with 3G.

  • I can't launch: Mail iCal n' Safari

    i can't Launch Mail iCal n' Safari the icon keep bunching in the Doc but nothing happens. Yet,i have no problem launching Words n' Firefox. any suggestions? Not being to open mail is horrible, lease help... Thanks in advance, ~ Grace

  • HT1414 how to delete a game on an iphone 4s

    how to delete games on iphone 4s

  • Modifying JList selection behavior

    What I want to do is change the selection behavior so that if the user clicks on the left half of the cell, the item is selected, but if the user clicks on the right half, the item is not selected. I already have the code to determine where the user