Using HttpUrlConnection Sockets?

In its implementation, java.net.HttpUrlConnection uses java.net.Socket or java.net.ServerSocket?

Thank you very much!

java.net.HttpUrlConnection uses java.net.Socket

Yes.

or java.net.ServerSocket?

N °

Tags: Java

Similar Questions

  • Bluetooth using RFCOMM Sockets

    Hello

    I'm working on a project that requires LabVIEW communicate with a raspberry Bluetooth Pi. The Pi is running Python and using PyBluez to the side of Bluetooth.

    Preference LabVIEW will connect to IP using a Socket Bluetooth on RFCOMM, however I can't find a way to open a socket in LabVIEW, only one channel. With the help of the RFCOMM VI build LabVIEW, I am able to see the IP (the name of the device and MAC themselves) but not connect to it.

    Does anyone know if this is even possible? I am currently using LabVIEW 2013 but the upgrade to a later version is an option if this support is included.

    See you soon,.

    Darren.

    Hi DazzaNL,

    You try to use LabVIEW as a server or a Client? If you use LabVIEW as a customer, you should be able to use the open connection VI Bluetooth to connect to a server.

    The examples for Bluetooth with LabVIEW locations are given in this paper and include an example of using LabVIEW as a server:

    http://www.NI.com/white-paper/3260/en/

    Hope this helps you,

  • How to use the Socket for AS3 networking?

    Hello, I'm a Flash game and have successfully obtained the RTMFP to work, but it is not very reliable and has a little loss of packages inside. I've heard many people only using TCP (socket), it is much tighter, but I have no idea on how to do it. I've Googled it many times, yet I really can't seem to find a clear answer. I hear you must have a server... How do you get one? Is it possible to make your own simple server that people your LAN can play? Thanks in advance.

    Yes, you can make your own simple server using the ServerSocket class and connect with the Socket class. And then you have TCP... it's actually pretty simple. Discover the ServerSocket docs to start, and there are also many examples if you googled around.

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/NET/ServerSocket. HTML

  • Use of socket in CS5 JS

    Hello.

    I got this request in another post, but it is hidden under an inappropriate topic, let so first apologized me for duplication. I'll remove the other post.

    In any case, I'm eager to open a http socket and post a message to a php page that connects to my mistakes and sent me e-mails.

    I can do this by using a JS-> Applescript-> shell script using the doScript method, but I need eliminate the need for a Mac.

    I can use the socket method to return data from a html page returned using a provided API, successfully so I know that the reception is possible, but perhaps there is a restriction on sending an argument.

    Here is the code that I use, it is a page on a live server, so if something is successful, it will be validated, and I will receive emails! Not that I don't mind, I just wanted to say.

    function combinedErrorReportWithSocket (errorText) //errorText is something like "library not found".

    {

    = myServerAddress ' automation.yappp .net: 80 ";

    errorText = encodeURI (errorText);

    Conn = new Socket();

    Conn.Open (myServerAddress);

    Conn.Write ("GET sendSrcError.php? e =" + errorText + ""-HTTP/1.0\n\n "");

    response = conn.read (999999);

    Conn.Close;

    }

    If this isn't a proper way to go about this, can someone suggest an alternative? I don't want to stay away from Applescript function however.

    Thanks in advance

    To?

    Answer your original thread, I would ask you do not divide the wire in the future.

    http://forums.Adobe.com/message/3963488#3963488

  • Only to get the pointer-nothing else; cannot be on/off switch. So, I use the socket on the wall?

    Can not get the computer; only to get the pointer so I turned off with the switch on the wall socket?

    Hello

    1. What is the brand and model of the computer you're using?
    2. what operating system is installed on the computer?
    3. any changes to the computer before the show?

     
    You can disconnect all external devices except the keyboard and mouse and check if you are able to boot to the desktop
     
    Method 1:
    I suggest you to start the computer in safe mode. Let us know if you face the issue in safe mode or not. Check out the link below to start the computer in safe mode:
    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode
     
    Method 2:
    I suggest you start WinRE (Windows Recovery Environment) and perform the Startup Repair.
     
    To start in WINRE and for more information about Windows RE view the following link.
    http://Windows.Microsoft.com/en-us/Windows7/what-are-the-system-recovery-options-in-Windows-7
     
    Once you start in WINRE try Startup Repair and check if this may help solve the issue, to perform the startup repair using the link below:
    http://Windows.Microsoft.com/en-us/Windows7/Startup-Repair-frequently-asked-questions
     
    Also check out the following link:
     
    I hope this helps!
  • SSL/tls over TCP using tcplistner socket or a tcpclient

    I am trying to use ssl/tls, TCP, but in my code, the socket is used not a tcpclient or tcplistner. I searched on the net at least 200 links but I have not everything related that. I want to use less coding and fact ssl or tsll during the tcp socket connection. I have a client, server, certification authority, a key to the .key format. Please help with the example.

    Hello

    TechNet support team can solve your problem correctly since your question is beyond the scope of what is generally answered here.

    Kind regards.

  • I have a problem when you try to receive data using the socket connection.

    Hello

    I created a socket connection between a pc (sever, win32) and a blackberry (client) and I have only two questions:

    -When I send a string to the sever I get the unexpected result, I doubt if it's a problem of encoding between platforms.

    -When I try to receive data, (an array of char as a string object), the customer demand freeze (drawing and management of events, so basically the main UI thread), even if I did all the stuff of connection in a separate thread, until I have shut down the server and also no data is received.

    I left the codes below and would assess any response from you.

    C++, win32 console application:

    SOCKET _Socket;

    int _tmain (int argc, _TCHAR * argv)

    {

    If (start_sever (_socket)) {}

    char r_msg [26];

    recv (_socket, r_msg, 26, 0);

    std::cout< "receive="" :="" "="">< r_msg=""><>

    char * s_msg customer = 'welcome ';

    Send (_socket, szMessage, strlen (S_MSG), 0);

    std::cout< "send="" :="" "="">< s_msg=""><>

    Sleep (500);

    Shutdown (_socket, SD_SEND);

    closesocket (_socket);

    WSACleanup();

    } else {}

    std::cout< "cannot="" initialize="">< std::endl="">

    }

    System ("pause");

    return 0;

    }

    BOOL start_sever (socket) {}

    WSADATA WsaDat;

    If (WSAStartup (MAKEWORD (2.2) & WsaDat)! = 0)

    {

    std::cout<"WSA initialization="">

    WSACleanup();

    System ("pause");

    Returns false;

    }

    Socket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);

    if(Socket==INVALID_SOCKET)

    {

    std::cout<"Socket creation="">

    WSACleanup();

    System ("pause");

    Returns false;

    }

    SOCKADDR_IN serverInf;

    serverInf.sin_family = AF_INET;

    serverInf.sin_addr.s_addr = INADDR_ANY;

    serverInf.sin_port = htons (8888);

    If (bind (Socket,(sockaddr*) (& serverInf), sizeof (serverInf)) == SOCKET_ERROR)

    {

    std::cout<"Unable to="" bind="">

    WSACleanup();

    System ("pause");

    Returns false;

    }

    Listen(Socket,1);

    SOCKET TempSock = SOCKET_ERROR;

    std::cout< "build="">

    while(TempSock==SOCKET_ERROR)

    {

    std::cout<"Waiting for="" incoming="">

    TempSock = accept (Socket, NULL, NULL);

    }

    Socket = TempSock;

    std::cout<"Client>

    Returns true;

    }

    Platform of Java for blackberry:

    public class Bush extends form {}

    -my current ipv4 address is set by default to avoid reset at each test

    TextField ip_text_field = new TextField ("IP address:", "192.168.65.1");

    -the server is waiting for any connection to this port ("8888")

    TextField port_text_field = new TextField ("Port:", "8888");

    ButtonField go_button_field = new ButtonField ("Connect", Field.FIELD_HCENTER) {}

    protected Boolean invokeAction (int action) {}

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}

    public void run() {}

    try {

    open_connection();

    }catch (System.Exception e) {}

    e.printStackTrace ();

    Dialog.Alert (e.getMessage ());

    }

    }

    });

    return true;

    }

    };

    public Socket() {}

    Super ();

    setTitle ("[taking sample]");

    Add (ip_text_field); ip_text_field.setMargin (20, 0, 0, 0);

    Add (port_text_field); port_text_field.setMargin (30, 0, 0, 0);

    Add (go_button_field); go_button_field.setMargin (30, 0, 0, 0);

    }

    public Boolean onClose() {}

    this. close();

    return true;

    }

    _Con StreamConnection;

    DataInputStream _in;

    OutputStreamWriter _out;

    public Sub open_connection() throws Exception {}

    _CON = (StreamConnection) Connector.open ("socket: / /" + ip_text_field.getText () + ":" + port_text_field.getText () +)

    » ; deviceside = true; interface = wifi");

    this.add (new TextField ("", "connected successfully to Server"));

    _in = _con.openDataInputStream ();

    _out = new OutputStreamWriter (_con.openDataOutputStream ());

    String msg = "Welcome to customer \r\n";

    _out. Write (MSG);

    String r_msg = _in.readUTF ();

    this.add (new TextField ("read from sever:", r_msg));

    _out. Flush();

    _in. Close();

    _out. Close();

    _CON. Close();

    this.add (new TextField ("", "data has been changed"));

    }

    }

    Thanks for your help.

    You treat on the thread of events.

    You have the following code:

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}

    public void run() {}

    try {

    open_connection();

    .....

    Now invokeLater essentially tells the operating system that the associated executable must be run on the event Thread.  You need start a separate Thread.  Extend this Thread, add your code in the run() method, and then start the Thread with start(). (not run()).  Then you must run the networking of processing on a separate Thread.

    This will cause you problems updating the user interface.  Take a look at this help:

    http://supportforums.BlackBerry.com/T5/Java-development/update-a-screen-on-the-main-event-thread/TA-...

    Printing, this means that invokelater a separate Thread is a common misconception.  I recommend you to look at this:

    http://supportforums.BlackBerry.com/T5/Java-development/what-is-the-event-thread/Ta-p/446865

    In addition, I recommend that you take a look at the socketDemo which must be included as a sample-, otherwise you can find it on github:

    https://github.com/BlackBerry/JDE-samples

  • Download a binary file using sockets without known length

    Hi all

    I am trying to download a binary (.exe) file using the socket, where the length of the file is not known. Please take a look at the code I use:

    var readBin = socketBin.read ();

    <-here's the code that checks the http Content-length header field

    ; If the field length of the content is available, then I will use it to download files, otherwise continue with the following code-->

    "pBar.reset (download plugin..", null); pBar.hit (readBin.length);

    While (1)

    {

    binFil.write (readBin);     'binFil' is the file in which the uploaded file is written.

    readBin = socketBin.read ();

    pBar.hit (readBin.length);

    If (socketBin.eof | readBin.length < = 0) {}

    Break ;}

    }

    binFil.write (readBin);

    binFil.close ();

    socketBin.close ();

    Problem is: I am able to download files within 10 seconds when the content length is known. But when the content length is not known, its about 1 and a half minute to download, also the progress bar gets hit for much of the time.

    FYI: socket is opened in binary mode, file is downloaded correctly (even if it takes abt a minute). BTW Im using extendscript CS5.5

    I am not able to understand where is the bug.

    Hi, Srikanth:

    Several points.

    #1 during the validation of code, please use the web interface and the > icon and choose syntax highlighting > Java. Otherwise your code is simply too difficult to read and gets the poster.

    #2 #1 apropos, your script, as written does not work, because this line:

    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$ 1/$2/$3/$4");
    

    has an extra $ 1 space and should be this:

    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$1/$2/$3/$4");
    

    Please take an extra moment to ensure that when ask you for help, you do so in a way that makes sense. Otherwise, it takes too much effort to help you, and it's frustrating.

    #3 If equip them us your script by adding a line to the loop while():

                while (1)
                {
                    binFil.write(readBin);
                    readBin = socketBin.read();
                    $.writeln(Date()+" Read "+readBin.length+" chars, eof is "+socketBin.eof);
                    if(  readBin.length<=0){         break;}
                }
    

    We get the output like this:

    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 631 chars, eof is false
    Mon Jul 11 2011 12:07:06 GMT-0400 Read 0 chars, eof is false
    Result: undefined
    

    So, we can reasonably conclude that the last reading at the end of the stream returns a short read when the other side blocks.

    Unfortunately, this is clearly insufficient since you can get short readings all the time.

    I don't know why you say we do not know the length of the file, HTTP, it provides you the Content Length of the response field.

    But the easy answer is to get the server to close for you. It's easy enough, with connection: close. Why were specify you

    Connection: keep-alive, what? :

                var requestBin =
                "GET /" + parsedURLBin.path + " HTTP/1.1\n" +
                "Host: " + parsedURLBin.address + "\n" +
                "User-Agent: InDesign ExtendScript\n" +
                "Accept: */*\n" +
                //"Connection: keep-alive\n\n";
                "Connection: close\n"+
                "\n";
    

    This gives a nice tidy:

    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 735 chars, eof is true
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 0 chars, eof is true
    

    I suspect, you are better to use something like socketBin.read(64*1024) for a 64 k buffer size, but it doesn't seem to affect the on-the-wire protocol, so maybe its not so important.

    If you do not want to answer on the server

  • Batchmodel: How to use the different positions of the switch-for EHR?

    Hello

    I use the Batchmodel OR three EHR. HAD the current number can be read from RunState.TestSockets.MyIndex.

    Can the lot this three EHR. What is the way - OR to use different maneuvers (OR-SwitchExec) to each dut?

    TestPlan is for example

    Configure the DMM

    Put

    Measure

    Turn off the switch.

    Switching is of course different for each Instrument.

    I really should add an if around each switching (= endless work) or is there an easy way that I'm not currently?

    If (RunState.TestSockets.MyIndex == 0)

    DUT1 switch

    Else if (RunState.TestSockets.MyIndex == 1)

    Switch to DUT2

    Else if (RunState.TestSockets.MyIndex == 2)

    Switch to DUT3

    on the other

    end

    Thanks for the tips

    Best regards

    OO

    I wouldn't use either of the prerequisite or if things... It's too much work and I'm lazy.

    I would just use the built in step of switching:

    http://zone.NI.com/reference/en-XX/help/370404G-01/NISE/TestStand/

    Name your routegroups in Switch Executive to match your shooting numbers.

    For example, in the process (s) to connect: box can have the following expression:

    "SigGenToUUT" + Str (RunState.TestSocket.MyIndex)

    And have a road connecting the signal generator to the UUT named SigGenToUUT0.  It would be for USE in socket 0.

    Just a thought!

  • Socket or Http

    HelloW...

    I have a guy to connect my application to internet I check first that its available interface... When I determined that the unit have put wifi «;» interface wifi = "or"; "device = true".

    buddy its in the beginning of the url I put

    http://XXXXXXXXX; Parameter or socket://xxxxxxxxxxx

    for example, I try whit http for wifi and the works, but here say that use the plug, so if use http its bad?

    and I have allways a port? in the docs, I see: 600

    http://supportforums.BlackBerry.com/T5/Java-development/different-ways-to-make-an-HTTP-or-socket-con...

    HTTP is a Protocol built on sockets. If you want to do a HTTP transaction (GET, POST, etc.), then you use http://... and when you create the connection, cast to an HttpConnection. If you're doing something else (streaming media or telnet, for example), then you don't use HTTP. You must use the socket: / /... and set up the connection to a SocketConnection.

    By default, HTTP port 80. By default, HTTPS uses port 443. Casings, however, generally do not have default ports and you specify one. Many ports have pre-defined uses; See, for example, http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

  • Unable to connect to the internet using Blackberry JDE...

    Hello

    I am trying to connect to internet using blackberry storm emulator...

    I'm trying to connect my midlet using the socket or with the default browser of the phone...

    nothing to do, is there anyone who can help me please?

    Your MDS runs.

  • ON SOCKET CONNECTIONS

    Im trying to make an app that connects 2 o more blackberry without the use of BIS, internet or wifi!... .im trying to do as an intranet and this is possible through a Socket connection, but I don't know what kind of technology should I use, because they ' r 2 just a lot in the tutorials and I don't know which one is the best for what im trying to do, help please?

    Welcome to the forums.

    A Socket connection being basically a TCP/IP connection, I think that the use of sockets fails your condition:

    "without the use of BIS, internet or wifi.

    Given the capabilities of the BlackBerry device, I don't think that you can create a generic intranet using any communication of peer to peer on a BlackBerry smartphone.

    I think it would be useful for you to review some of the many tutorials so that you better understand the platform capacity.

  • Problem creating socket in Blackberry 6 connection

    I have an application that connects to a server over tcp using the socket «;» deviceside = true' flag... the app works fine on other games except, "BOLD", which is being upgraded to OS 6.0 blackberry... any help would be greatly appreciated...

    Thank you.

    As dx22, I would like to know the error you see too,

    I also want to confirm that you are aware of the different methods of connection and the implications of these.  « ; deviceside = true is one of the many options that, as you see here:

    http://supportforums.BlackBerry.com/T5/Java-development/different-ways-to-make-an-HTTP-or-socket-con...

    Specific to the «;» deviceside = true' is the condition for APN information, perhaps the reason that your OS 6.0 device does not connect is tat this device doesn't have the correct information of the AFN.

    This could help you automate finding the information of the AFN.

    http://supportforums.BlackBerry.com/T5/Java-development/what-is-default-TCP-service-record/Ta-p/9394...

  • How to connect through the connection Socket BIS?

    Hi all, I am trying to connect to Socket BIS. I'm able to establish BIS my service provider Http connection. I downloaded a chat application that checks the types of networks supported by my device/package that has the following list:

    (1) BIS-Http: OK

    (2) BIS-SOCKET: OK

    (3) BES-HTTP: NA

    BES-SOCKET 4): NA

    (5) TCP-HTTP: BAD DNS

    (SOCKET TCP-6): EXPIRED

    I know direct TCP is not supported by my ISP. So I would use BIS-Socket connection. Can anypne please help me reach this type of connectivity? Help, please. Thanks in advance.

    as a member of the alliance, you can apply to BIS-B access with an application. you get your own connection key that you can use to create connections of bis - b.

  • socket InputStream does not get all the data, please help

    I've been doing stuff of network on blackberry for quite awhile, but still using the http connection.

    I have to use the socket for a piece of my application connection, but could not do the work.

    This code is what I do

    String url =

    "socket: / / ' + rmserver + ': ' + rmport;

    Socket SocketConnection = Connector.open (url) (SocketConnection);

    socket.setSocketOption (SocketConnection.KEEPALIVE, 1);

    OutputStream = socket.openOutputStream ();

    InputStream = socket.openInputStream ();

    send something here using outputstream

    int

    If (f > 0) {}

    do somwthing

    }

    AV is always 0.

    I don't know that my server sends data successfully. I run the network packet capture tool etheal on the MDS Server, I can see given reached MDS Server, but they never come to my device app.

    The outputstream works very well, I can send data from my application and my server code gets all of them.

    Where should I check? If it is http, I can turn on the debugging http on MDS log and see all network traffic, but for the socket connection, data packet is not connected (or I missed where it is).

    Is someone can you please tell me where I should go to understand why?

    Please try the suggestion to remove the check mark on InputStream.available.

Maybe you are looking for

  • access to the Clipboard

    Hi people, IM thinking of switching IE10 browsers to firefox. In IE10 I could control programmatic access to the Clipboard by disabling and so stop the Web sites of the capture of text/data I stored in the local Clipboard. What is firefox to stop thi

  • Make my computer 'No Marilyn' more

    Hello! I intend to buy a new desktop MAC in a few weeks and give my only current to my nephew.  Apart from the deletion of my personal files, how is more make a computer "Marilyn"... whereas when Jacob click on mail, he gets HIS mail and not mine.  U

  • Windows 11 media won't start - resolved by reinstalling Windows Media Player 11

    I can't get media 11 start... anyone have the same problem?

  • Cannot delete directory tree

    I had a request are able to convince Windows to screw up its file structure in two folders. When I try to delete the directory runaway tree I get the message error "the folder contains items whose names are too long for the Recycle Bin.  After choosi

  • InvokeManager has not declared in this scope

    Hey guys How are you today?, hoping you're all going well I have a weird bug that continues to show the material to what I did for me I did a class, spicific for invocations to my email, twitter account etc... I took the code from the site blackberry