×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Creating UPD TCP Connection

    Hi all,

    I am looking for basic code example of how to initiate a
    simple TCP/UDP connection from the mobile phone to a regular PC using a specific ip and port numbers, so that i will be able to transfer any data between the mobile phone and the PC,
    (I already know, i need to create socket but i just don't know how to do all that stuff on the mobile phone)

    regards,
    Eugene

  2. #2
    Regular Contributor
    Join Date
    Aug 2007
    Location
    India
    Posts
    83

    Re: Creating UPD TCP Connection

    Go through this link

    http://developers.sun.com/mobility/m...ericframework/

    Hope this will helps you

  3. #3
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    51

    Re: Creating UPD TCP Connection

    for TCP u can use something like this in client mobile:
    Code:
    // create a TCP socketconnection to the server
    
    SocketConnection obSocketConnection = (SocketConnection)Connector.open(socket://"+URLserver+":"+serverPort);
    // Disable Nagle algorithm: 
    
    obSocketConnection.setSocketOption(SocketConnection.DELAY, 0);
    // open the input and output streams
    
    InputStream in = obSocketConnection.openInputStream();
    OutputStream out = obSocketConnection.openOutputStream();
    and something like this in server :
    ServerSocket obServerSocket = new ServerSocket(iTCPport);
    while(true){
    //create a TCP Socket Connection to Client
    Socket obClientSocket = obServerSocket.accept();
    if (!useNagle)
    obClientSocket.setTcpNoDelay(true);
    for UDP u can use something like this in client mobile:
    Code:
    DatagramConnection  obDatagramConnection = (DatagramConnection) Connector.open(sURLserver);
    Code:
    Datagram obReceiveDatagram = obDatagramConnection.newDatagram(obDatagramConnection.getMaximumLength());
    obDatagramConnection.receive(obReceiveDatagram);
    Code:
    Datagram obSendingDatagram = obDatagramConnection.newDatagram(sendData,sendData.length);                           
    obDatagramConnection.send(obSendingDatagram);
    in server :
    Code:
    DatagramSocket obServerDatagram = new DatagramSocket(iUDPport);
    DatagramPacket in = new DatagramPacket(byteReceiveBuffer, byteReceiveBuffer.length);
    obServerDatagram.receive(in);
    hope it can help

    best regards
    adek aidi

Similar Threads

  1. Creating connection to iap and opening browser
    By ollipekkam in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-07-04, 15:07
  2. TCP Problems when run on phone - connection error -46
    By daveataxon in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-04-17, 19:00
  3. Replies: 1
    Last Post: 2007-03-26, 08:17
  4. Datagram Connection (TCP and UDP) in Nokia 6600
    By hbfornies in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-11-11, 22:29
  5. TCP connection over GPRS on the Series60 Emulator
    By dannywoodz in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2002-09-04, 07:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •