A secret class in logging ocket programming _ Javascript tutorial

Source: Internet
Author: User
JavaSocket: A secret class in Java & nbsp; Socket programming, Javascript tutorial

Introduction

The Java platform implements Socket in the java.net package. In this article, we will use the following three classes in the Java.net package to work:

URLConnection
Socket
ServerSocket

There are more classes in the java.net package, but these are the most common ones. Let's start with URLConnection, this class provides the method of using Socket in your java code without understanding the underlying mechanism of Socket.

You can use sockets without even trying.

To connect to a URL, follow these steps:

Create a URLConnection

Configure it using different setter Methods

Connect to URLConnection

Interaction with different getter Methods

Next, we will use some examples to demonstrate how to use URLConnection to request a document from a server.

URLClient class

We will start with the structure of the URLClient class.

Import java. io .*;
Import java.net .*;
Public class URLClient {
Protected URLConnection connection;
Public static void main (String [] args ){}
Public String getDocumentAt (String urlString ){}
}

Note: you must first import the java.net and java. io packages.

 

[1] [2] [3] Next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.