MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

TCPSocket

번역 작업 진행중입니다.

This API is available on Firefox OS for privileged or certified applications only.

요약

The TCPSocket interface provides access to a raw TCP socket.

The main entry point for this API is the navigator.mozTCPSocket property which is a TCPSocket object.

참고: 인증 된 앱만 1024보다 작은 포트에서 들어오는 연결을 허용 할 수 있습니다.

API 개요

interface TCPSocket{
  readonly attribute DOMString host;
  readonly attribute unsigned short port;
  readonly attribute boolean ssl;
  readonly attribute unsigned long bufferedAmount;
  readonly attribute DOMString binaryType;
  readonly attribute DOMString readyState;

  TCPSocket open(DOMString host, unsigned short port, [object options]);
  TCPServerSocket listen(unsigned short port, [object options, [unsigned short backlog]]);
  void upgradeToSecure();
  void suspend();
  void resume();
  void close();
  boolean send(in jsval data);

  attribute onopen;
  attribute ondrain;
  attribute ondata;
  attribute onerror;
  attribute onclose;
};

속성

TCPSocket.host Read only
A string representing the host name of the server the socket is connected to.
TCPSocket.port Read only
A number representing the port the socket is connected to.
TCPSocket.ssl Read only
A boolean indicating whether the socket is encrypted with SSL (true) or not (false).
TCPSocket.bufferedAmount Read only
The number of bytes of not-yet-sent data in the socket buffered.
TCPSocket.binaryType Read only
The type of data used. Possible value is arraybuffer or string.
TCPSocket.readyState Read only
The socket state. Possible value is connecting, open, closing, or closed.

이벤트 핸들러

TCPSocket.onopen
A handler for the open event. After this event, the socket is ready to send and receive data.
TCPSocket.ondrain
A handler for the drain event. This event is triggered each time the buffer of data is flushed.
TCPSocket.onerror
A handler for the error event.
TCPSocket.ondata
A handler for the data event. This event is triggered each time data has been received.
TCPSocket.onclose
A handler for the close event.

메소드

TCPSocket.close()
Closes the connection.
TCPSocket.open(host, port [, options])
Returns a new TCPSocket object connected to the given host at the given port.
TCPSocket.listen(port [, options [, backlog]]) Requires FirefoxOS 1.2
Returns a new TCPServerSocket object listening at the given port.
TCPSocket.resume()
Resumes the data events.
TCPSocket.send(data)
Buffers data to be sent across the network.
TCPSocket.suspend()
데이터 이벤트를 일시 정지합니다.
TCPSocket.upgradeToSecure() Requires FirefoxOS 1.2
채널에서 보안 사용합니다.

Specification

아직 사양에 포함되어 있지 않습니다. 그러나이 API는 W3C에서 TCP 및 UDP Socket API (이전에는 Raw Sockets API) 제안에 따라 시스템 응용 프로그램 작업 그룹의 일부로 논의되었습니다.

관련항목

문서 태그 및 공헌자

 이 페이지의 공헌자: Shin-JaeHeon
 최종 변경: Shin-JaeHeon,