Sending an InetAddress-object via udp

hi there!
i'm developing a videostream server/client application. client is an applet. what i want to do is this:
since an applet has to be signed in order to perform dns-lookups, i want to work around that.
since the applet has to request the stream anyway and therefore connects the server sending udp-
packets, my idea was to let the server send back the clients IP/hostname as an InetAddress-object
inside a udp packet.
i tried the following:
info: byte[] buf = new byte[256];
on server:
InetAddress address = packet.getAddress();
buf = address.getAddress();
packet = new DatagramPacket(buf, buf.length, address, port);
socket.send(packet);
on client:
socket.receive(packet);
byte[] temp = packet.getData();
source = InetAddress.getByAddress(temp);
System.out.println(source.toString());
the system.out returns this: ı�A)
or other unreadable stuff, depending on the ip-address of the client.
i think, this has something to do with the conversion to/from bytearray, doesn't it?
can anyone show me how to send an InetAddress-object so that i get an
InetAddress-object out at the client side?
thanks in advance!
you can earn some bucks, too!
greets
honfrek

hi there!
thanks for your help. i got it figured out now.
now it works like this:
on server:
InetAddress address = packet.getAddress();
buf = address.getAddress();
byte[] newbuf = new byte[buf.length];
newbuf = buf;
packet = new DatagramPacket(newbuf, newbuf.length, address, port);
socket.send(packet);
on client:
byte[] newbuf = new byte[4];
packet = new DatagramPacket(newbuf,newbuf.length);
socket.receive(packet);
source = InetAddress.getByAddress(packet.getData());
i made 2 mistakes:
- i converted the InetAddress to a string
- the length of the byte[] was too big. i had a bunch of zeroes at the end

Similar Messages

  • Sending File object via  UDP

    Hello...
    i have 2 applications...a server and a client..i want to send a file object or any self declared object from the server to the client application.How can i accomplish this.Do i still have to use byte arrays. Can u help me with this.
    Thanks in advance.

    Bear in mind that the File object - I'm assuming you mean an instance of java.io.File here - isn't "the file", it's just a handle to the file. Sending that itself is pointless, since it describes a file on your local machine, which will mean nothing to another machine. You need to read in the actual bytes of that file and send them

  • Getting RuntimeException while sending a JMenu Object via http

    Hello,
    since Java 1.5.0 i use a mechanism, which transfers a JMenu from my servlet object to my applet object via http.
    Now since 1.5.0_02 i get this Exception while doing it:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.swing)
    Now there is nothing to find about this. Not here in the forums, neither in google or anywhere else.
    My guess is, its a matter of deserialization of thoses Jmenus.
    Anybody out there with the same problem?
    Anybody knows how to solve this WITHOUT changes the policy?
    thanks
    steffan

    The directory that contains msgsend.class (usually the current directory)
    is not in your CLASSPATH setting. Be sure that "." is included as one of the
    entries in CLASSPATH.

  • How to send a Connection Object via CORBA

    Hi.
    I've got a question.
    How can I send a java.sql.Connection object
    using CORBA to a client? Tried to use a class
    MyConnection extending org.omg.CORBA.portable.ObjectImpl
    as a wrapper class. Didn't work.
    When a request was invoked for a Connection,
    no object was send. On client side an error occured:
    code 202 completed:maybe.
    In the IDL we used:
         typedef Object MyConnection;
         interface ConnectionPool{
              MyConnection getCon();
              void freeCon(inout MyConnection c);
    We were suggested to use structures. But ain't it
    inventing java again?
    Can anyone help us?
    Thx anyway.

    Try inserting it into an Any object and sending the any object over the IDL, the client can then extract the connection object.
    You might have to typedef the Connection object in the IDL to generate the helper class.
    /P/

  • Send a ResultSet object via RMI - won't work.

    Hi. I make a user interface to access MySQL database. The access to MySQL server is done from a remote location via RMI. The process to delete/update/create was succeed. The only problem is when I try to get(from the client computer) the ResultSet object, that come from invoking statementObject.executeQuery(myQuery) method, from the server Computer: it won't work. It said that the ResultSet object is not serialized(it is an interface). I need the ResultSet object for my client program since I will use it to set my AbstractTableModel class's object. Last goal is to put the AbstractTableModel object into the JTable constructor so I can see the result from a table.
    Is anyone can help me? I can not return the ResultSet object to the client since it is not serialized.

    I use the following solution using List. As List is Serlizable I can throw it across the network using RMI... it is also of course easy to access.......
    For users objects you need to throw across the network just simply make them implement Serializable
    In your ORM class accessing the DB:
    public List getSQLResults{
    Resultset SQLResults = statement.executeQuery(SQLQuery);
    Vector results = new Vector();
    while (SQLResults.next()){
    // create class object here if needed...
    results.add(SQLResults.getStrinf("COL_NAME");
    return results;In your GUI class..
    JTable theTable = new JTable();
    DefaultTableModel theModel = new DefaultTableModel();
    theModel.addColumn(SOME_COLUMN);
    try{
    List resultsData = ORMClass.getSQLResults();
    Iterator iterator = List.Iterator();
    while(iterator.hasNext()){
    iterator.next();
    theTableModel.addRow(SOME_OBJECT);
    theTable.setModel(theModel);
    catch(Exception ex){
    // exception rasied...... do something!!!
    }

  • Sending a Socket Object via a Socket :P

    eek Sorry all! I accidentally posted in "Java Programming" 1st... I don't know how to delete my post
    http://forum.java.sun.com/thread.jspa?threadID=5261765&tstart=0

    why ?
    At server side you can use input and output streams for communication.
    for example:
    You can have hashmap at serverside and put resp. sockets in it w.r.t. loginid.
    So you have
    key - socket
    loginA - SocketA
    loginB - SocketB
    now write "serialized" message class
    class Message implements Serializable {
    String from,to,message;
    // getter and setters for all
    put this class at client and serverside.
    When B will writeObject(message) to A he will actually writeObject(message) to server.
    Server will use getTo() method of class message.
    Server will get Socket from hashmap using getTo() "key" and will writeObject(message) To A
    Bye the way I am still curious why you want to send socket ?

  • How does one send a file via UDP?

    I need to send a binary file via UDP. The file has 99 32-bit binary words of data. How do I input the data to the UDP write command? I don't want to send the data sequentially..I would like to send all 99 words in a single UDP transmission. TIA.
    -jlivermore

    Something to be careful of is that while UDP is fast, it is not secure. You can lose packets and there is no way for the sender or receiver to know it was lost. Because UDP doesn't have a "connection" like TCP does, the sender doesn't know if the data is going anywhere and the receivers have no way of knowing if anything is being sent.
    Picture a radio station. A guy working the night shift hopes there is someone somewhere listening to his broadcast, but he doesn't know. Likewise, if you turn on a radio and hear nothing but static, you may be listening to a frequency where there are no stations broadcasting, or the station transmitter might be off the air, or there might be interference keeping you from hearing the signal, but again you don't know which.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Error in sending object via a JMS..

    The JMS is giving me error when i am sending an object via a sender...i am using point to point,...and Weblogic server....
    the whole thing of object sending works when i run it in two different consoles...i
    but when i move to webworld....i e tomcat it shows me the following exception.....
    weblogic.jms.common.JMSException: Error deserializing object
    at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:144)
    at intertec.jms.ObjectReceiver1.onMessage(ObjectReceiver1.java:64)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2596)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:2516)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.Kernel.execute(Kernel.java:336)
    at weblogic.kernel.Kernel.execute(Kernel.java:360)
    at weblogic.kernel.Kernel.execute(Kernel.java:348)
    at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:2392)
    at weblogic.jms.client.JMSSession.invoke(JMSSession.java:2919)
    at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:609)
    at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsyncInternal(DispatcherImpl.java:128)
    at weblogic.jms.dispatcher.DispatcherImpl.dispatchOneWay(DispatcherImpl.java:312)
    at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Caused by: java.lang.ClassNotFoundException: intertec.beans.Emp
    at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:891)
    at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:756)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at weblogic.jms.common.ObjectMessageImpl$ObjectInputStream2.resolveClass(ObjectMessageImpl.java:305)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
    at java.util.Hashtable.readObject(Hashtable.java:841)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
    at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:130)
    ... 21 more
    thanks in advance....
    regards
    ullas

    You are missing a class:
    Caused by: java.lang.ClassNotFoundException: intertec.beans.Emp

  • Sending character array (as a bytebuffer) via udp

    Hi,
    I do have to send a udp packet, containing several variables, and the reciever awaits it as a character array ... (C++, cannot change this part!)
    As far as I see it, I can only send ByteBuffers via DatagramPackets via udp.
    Has anyone a clue how I can convert a ByteBuffer into another Bytebuffer in a way so that the udp reciever gets it as if I had sent a character array instead ?!?
    Or is there actually a character array udp sender ?!?
    Any help is highly appreciated, big Thanx in advance,
    ~Carmela

    In C++, char' are unsigned bytes. Thus converting between bytes and chars is fairly straight forward. Java treats char as unsigned short (16-bit) so it converts chars to bytes as UTF-8. (By default) Unless you are using special on ascii characters i.e. 128+ all this makes no difference whatsoever.
    A bytebuffer is just a container for bytes. You can encode anything as bytes so there is no magic here. Just get the data as bytes and put it into a ByteBuffer.
    String string = "text";
    ByteBuffer bb = ByteBuffer.wrap(string.getBytes());

  • How to know method name dynamically with sender or EventArgs object

    Hello All,
    I am working in ASP.NET. I wanna log method name in log file whenever that method is executed. e.g.
    protected void Page_Load(object sender, EventArgs e)
    Trace.Log("Page_Load start");
    Trace.Log("Page_Load end");
    protected void Method2(object sender, EventArgs e)
    Trace.Log("Method2 start");
    Trace.Log("Method2 end");
    Trace.Log() is use to log my string in log files at D:\. Now, here I have hard coded Method name in Trace.Log(). But, now I want to fetch method name via c# code. Can we achieve it via sender or EventArgs object?
    Please assist.
    Thanks, Chintan

    Hello Chintan,
    You can get class name through reflection as it gets STATIC info about the component.
    However, to get the line number of an exception, which is a run time parameter, you cannot use reflection.
    I actually have not tried this before but, given it did not work for you in the web part class, you may try the below code in your *.ascx.cs user control used by your visual web part.
    //To Retrieve class name use this line:
    string className = this.GetType().FullName;
    // To retrieve other parameters including line number
    try
    TestFunction();
    catch (Exception ex)
    StackTrace st = new StackTrace(ex, true);
    StackFrame[] frames = st.GetFrames();
    // Iterate over the frames extracting the information you need
    foreach (StackFrame frame in frames)
    string stkFrame = string.Format("{0}:{1}({2},{3})", frame.GetFileName(), frame.GetMethod().Name, frame.GetFileLineNumber(), frame.GetFileColumnNumber());
    For more info, please refer to this
    post.
    THosE wHo doN'T apPreCiATe LiFe, DOn't DeSerVe iT

  • Sending Data to BAM via web service

    Is it possible to send data to BAM data objects via web service / http soap ? I know we can call extenal web service from BAM, but I was thinking of doing a real time from source application to BAM via http-soap web service.

    Hi,
    I hope it es not too late for an answer ...
    Yes you can do that .... have a look to this example
    procedure UpSert_DO (do_name VARCHAR2, do_key VARCHAR2, xmlload VARCHAR2) is
    begin
    --'<_NAME>HZ.01.10</_NAME></_WS>
    http_post(
    'http://localhost/OracleBAM/Services/DataObject/DataObjectOperations.asmx',
    '<?xml version = ''1.0'' encoding = ''UTF-8''?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://xmlns.oracle.com/integration/bam">
    <env:Body><ns0:Upsert><ns0:dataObject>' || do_name || '</ns0:dataObject><ns0:keyCSV>do_key</ns0:keyCSV><ns0:xmlPayload>' || do_key ||
    xmlload ||
    '</ns0:xmlPayload></ns0:Upsert></env:Body></env:Envelope>',
    'text/xml; charset=UTF-8',
    null,
    null,
    'USER_NAME',
    'PASS_WORD',
    '"http://xmlns.oracle.com/integration/bam/Upsert"'
    end;

  • Transmitting a byte command via UDP

    I hope you'll forgive the newbie question, but my education is in aerospace engineering and not computer science...
    I have a verified specification document which tells me that in order to command a data source to begin transmitting data, I need to send it the following command via UDP:
    1 byte        1 byte               2 bytes                              n bytes
    COMMAND
    01
    00
    Command Code =
    8016
    Data  
    Where the data field is ignored for this command.
    My best understanding of this situation would be to use the Byte Array to String function on an array of U8s which looks like this:
    where the network order is big endian.  However, I have some functioning, inherited code which interfaces with the same data source and issues a start data command using an array which looks like this:
    In classic style, the author of this code has retired and I'm the only other LabVIEW programmer.  I'm not savvy enough to tell whether this array accomplishes the same task and it's my limited understanding of bytes which is causing the confustion or if this command is combined with another command or what.
    Any insight, leading questions, or valuable commentary is appreciated.
    Solved!
    Go to Solution.

    I think I'm starting to understand how bits, bytes, and such behave with LabVIEW.  Kind of confusing without a solid background in computing...
    According to the documentation-when using the startup command--there is no data payload required; it is ignored by the data source.  My only guess for those elements remaining after the 4th element are that they are simply placeholders so that the data source know this is a completed command or that the original programmer copied the array from one of the other commands (which required the data payload) and those are just residual values he knew were ignored and never bothered to delete.  It would be in keeping with the just-get-it-done approach this programmer favored.
    Thanks for the assistance.  I think I can interpret the other commands for this data source now.
    Cheers.

  • Problems starting tcode from swo1-object via gos (so_sendobj)

    Hi,
    working with gos around some swo1-object, i got the problem to start a transaction which is called from an object method: the transaction starts but the wished details of that item do not appear as expected.
    When I start the test environment within tcode SWO1, and at first, I create an instance from this object giving it the right key (for the wished item) then i succeed in starting the bespoken transaction from within that method showing me the details for that item.
    In the last days, I have read and learned a lot about the possibilities and interdependences of the gos mechanism using many of the hints and advices which were given here in the forum in the past. But I'am not able to achieve the wished effect via gos (send object with note) from within our application.
    My guess, we need to start an instance of the object before we can show details for the wished item. In the normal case, the application shows at the left windows with containers/trees for search filters and items and within the main window on the right the details for that item. Starting this transaction a popup-window appears (showing the standard filter) where you can give the wished item no.
    As I remarked, starting all these things from within the swo1 environment everything is functioning as expected...
    Is there anybody who has made a similar experience and can give me some advice what we have to do to succeed in?? Is there any function module of kind SWU..., SWE... SWO... or something else which is to be called in front of that task???
    I forgot to mention that within our application, there is the correct? built up of the gos-object via class cl_gos_manager constructing the needed object and the needed key, so when calling the gos-action, the bypassed sap user finds the link in the inbound position and will be directed to the correct transaction with the side effects described before.
    Wish you all together a happy new year.
    Kind regards
    Christian

    My freind  ,
    in the   Bussiness Objects  migatration there is  no select-options  like   
    sending  range of data  or the multiple selections.
    for this we need separate   loop structure   where in we can send the multiple   data  and everytime it calls the  BAPI Obect  evertime  individaully ,
    if you want the  you have to  define  one  new   BOR  object  (Custom bapi)...then  rignt  one  function module for   select-options and  attach it to  you method  in the BAPI   .
    So that   your  BAPI calls  in the SAP  function Module   for  range of data .
    Reward  points if it is  usefull ....
    Girish

  • I'm having a problem sending a word doc via email. I have Mac for Office 08, when I save the document as a .doc or .docx, and send it to someone, they receive it as a blank document. Yet, when I open it on my Mac, it has a "word" icon. How do I fix?

    I'm having a problem sending a word doc via email. I have Mac for Office 08, and I'm using Mavericks OS. When I save the document as a .doc or .docx, and send it to someone, (doesn't matter if its safari, chrome or firefox or on my yahoo or gmail accounts) they receive it as a blank document. Yet, when I open it on my Mac, it has a "word" icon and I can read it. How do I fix?

    I suggest you post on the Microsoft Mac forums since it's their software you're having issues with.
    http://answers.microsoft.com/en-us/mac

  • Best practice "changing several related objects via BDT" (Business Data Toolset) / Mehrere verbundene Objekte per BDT ändern

    Hallo,
    I want to start a
    discussion, to find a best practice method to change several related master
    data objects via BDT. At the moment we are faced with miscellaneous requirements,
    where we have a master data object which uses BDT framework for maintenance (in
    our case an insured objects). While changing or creating the insured objects a
    several related objects e.g. Business Partner should also be changed or
    created. So am searching for a best practices approach how to implement such a
    solution.
    One Idea was to so call a
    report via SUBMIT AND RETURN in Event DSAVC or DSAVE. Unfortunately this implementation
    method has only poor options to handle errors. Second it is also hard to keep LUW
    together.
    Another idea is to call an additional
    BDT instance in the DCHCK-event via FM BDT_INSTANCE_SELECT and the parameters
    iv_xpush_classic = ‘X’ and iv_xpop_classic = ‘X’. At this time we didn’t get
    this solution working correctly, because there is always something missing
    (e.g. global memory is not transferred correctly between the two BDT instances).
    So hopefully you can report
    about your implementations to find a best practice approach for facing such
    requirements.
    Hallo
    ich möchte an der Stelle eine Diskussion starten um einen Best Practice
    Ansatz zu finden, der eine BDT Implementierung/Erweiterung beschreibt, bei der
    verschiedene abhängige BDT-Objekte geändert werden. Momentan treffen bei uns
    mehrere Anforderungen an, bei deinen Änderungen eines BDT Objektes an ein
    anderes BDT Objekte vererbt werden sollen. Sprich es sollen weitere Objekte geänderte
    werden, wenn ein Objekt (in unserem Fall ein Versicherungsvertrag) angelegt
    oder geändert wird (zum Beispiel ein Geschäftspartner)
    Die erste unserer Ideen war es, im Zeitpunkt DSAVC oder DSAVE einen
    Report per SUBMIT AND RETURN aufzurufen. Dieser sollte dann die abhängigen Änderungen
    durchführen. Allerdings gibt es hier Probleme mit der Fehlerbehandlung, da
    diese asynchrone stattfinden muss. Weiterhin ist es auch schwer die Konsistenz der
    LUW zu garantieren.
    Ein anderer Ansatz den wir verfolgt hatten, war im Zeitpunkt
    DCHCK per FuBA BDT_INSTANCE_SELECT und den Parameter iv_xpush_classic = ‘X’ and
    iv_xpop_classic = ‘X’ eine neue BDT Instanz zu erzeugen. Leider konnten wir diese
    Lösung nicht endgültig zum Laufen bekommen, da es immer Probleme beim
    Übertragen der globalen Speicher der einzelnen BDT Instanzen gab.
    Ich hoffe Ihr könnt hier eure Implementierungen kurz beschreiben, dass wir
    eine Best Practice Ansatz für das Thema finden können
    BR/VG
    Dominik

Maybe you are looking for

  • FCC for file receiver help

    Hi all, My source xml is: node1_mt <node2>   <node3> 0 to u      field1      field2      field3      <node4> 0 to u         fielda         fieldb         fieldc      </node4>   </node3>   fieldaa   fieldbb My target file should be: (csv) field1 field

  • URGENT -- cannot save word document

    When I try to save a Word doc on my macbook I get a message that says "too many files are currently open" and the document cannot be saved.  Does anyone know what to do please?

  • Error de instalación de prueba para Adobe Flash Professional CS6 (Exit Code: 34)

    eh estado intentando instalar la vercion de prueba de Adobre Flash CS6 y me marca este error: - 1 fatal error(s), 0 error(s), 0 warning(s) FATAL: Payload '{0A1E2FE2-B2AD-42F4-9C74-641853FB093A} Photoshop Camera Raw 7 6.0.98.0' information not found i

  • Update existing trial version to a productive one

    Hi there, Is it possible to change the licence key of an existing trial version installation of Lifecycle ES? I haven´t found an option in the adminui or the configuration manager. Any ideas, how to solve that? Greetings, Joerg

  • SPNego Configuration

    Hi All, We have configured SPNego on customer's sand box and DEV as mentioned in the thread https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8235, however when we tried configureing on QA system, we are getting the following error. UME cannot re