JP6061480B2 - Communication device control method and communication device - Google Patents

Communication device control method and communication device Download PDF

Info

Publication number
JP6061480B2
JP6061480B2 JP2012060234A JP2012060234A JP6061480B2 JP 6061480 B2 JP6061480 B2 JP 6061480B2 JP 2012060234 A JP2012060234 A JP 2012060234A JP 2012060234 A JP2012060234 A JP 2012060234A JP 6061480 B2 JP6061480 B2 JP 6061480B2
Authority
JP
Japan
Prior art keywords
connection
port number
communication
port
connection process
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2012060234A
Other languages
Japanese (ja)
Other versions
JP2013196122A (en
Inventor
亮輔 佐藤
亮輔 佐藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Canon Inc
Original Assignee
Canon Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Canon Inc filed Critical Canon Inc
Priority to JP2012060234A priority Critical patent/JP6061480B2/en
Publication of JP2013196122A publication Critical patent/JP2013196122A/en
Application granted granted Critical
Publication of JP6061480B2 publication Critical patent/JP6061480B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、通信に使用するポート番号を決定する際の通信装置の制御方法及び該制御方法を実行する通信装置に関する。   The present invention relates to a communication device control method for determining a port number used for communication and a communication device that executes the control method.

通信装置同士が通信するためのプロトコルとして、TCP(Transmission Control Protocol)がある。多くの一般的なプログラム環境において、TCPの動作はOSの一部として実装される。また、ユーザランドで動作するアプリケーションはOS(Operation System)が用意するAPI(Application Program Interface)を使用することでTCPを用いた通信処理を行う。例えばUNIX(商標登録)では、Socketと呼ばれるAPIでこの機能を実現している。
またTCPでは、TCP通信を行う装置上で動作する送受信アプリケーションを識別するために、ポート番号と呼ばれる16ビットの識別子を使用する。異なるアプリケーション間で同一のポート番号が使用されることを防ぐために、TCPを実装するOSでは通常ポート番号の重複利用が発生していないかを確認する重複チェックを行っている。例えばUNIX(商標登録)では、アプリケーションがポート番号を指定するbind関数において重複チェックを行っており、すでに他のアプリケーションがポート番号を使用している場合は、当bind関数呼び出しがエラーで返るようになっている。これによってアプリケーションは、自らが使用したいポート番号が実際に使用できるかどうか確認することが可能になる。また、使用できない場合には別のポート番号を使用するといったような対処を行うことができる。
As a protocol for communication apparatuses to communicate with each other, there is TCP (Transmission Control Protocol). In many common program environments, TCP operations are implemented as part of the OS. An application operating in the userland performs communication processing using TCP by using an API (Application Program Interface) prepared by an OS (Operation System). For example, in UNIX (registered trademark), this function is realized by an API called Socket.
In TCP, a 16-bit identifier called a port number is used to identify a transmission / reception application operating on a device that performs TCP communication. In order to prevent the same port number from being used between different applications, an OS that implements TCP performs a duplication check to confirm whether or not normal use of the port number has occurred. For example, in UNIX (registered trademark), when an application performs a duplication check in a bind function that specifies a port number, and another application already uses the port number, the bind function call is returned with an error. It has become. This allows the application to check whether the port number that it wants to use can actually be used. Further, when it cannot be used, it is possible to take measures such as using another port number.

特開平11−175439JP-A-11-175439

しかしながら、開発プラットフォームによっては、上記のような重複チェックの機構が用意されていない場合がある。また用意されていても、詳細な動作仕様がアプリケーション開発者に開示されないような開発環境も存在する。このような環境において、アプリケーションは使用したいポート番号が実際に使用できるかどうか確認することが出来ず、実際には使用できないポート番号を使用できるものとして誤認してしまう懸念があった。
本発明は上記課題に鑑みてなされたものであり、ポート番号の重複チェック機能の動作が明確でない状況においても、特定のポート番号が使用できるかどうか確認できるようにすることを目的とするものである。
However, depending on the development platform, there is a case where the above-described duplication check mechanism is not prepared. There are also development environments in which detailed operation specifications are not disclosed to application developers even if they are prepared. In such an environment, there is a concern that the application cannot confirm whether the port number that the user wants to use can actually be used, and misidentifies that the port number that cannot actually be used can be used.
The present invention has been made in view of the above problems, and it is an object of the present invention to make it possible to check whether a specific port number can be used even in a situation where the operation of the port number duplication check function is not clear. is there.

本発明の通信装置は、通信インタフェースの所定のポート番号に接続する接続処理を行う接続手段と、前記接続手段による前記接続処理が成功した場合、前記接続手段による前記接続処理が失敗するまで、接続するポート番号を切替えながら、前記接続手段が前記接続処理を行うように制御する制御手段と、前記接続処理が失敗したことに応じて、当該接続処理に失敗したポート番号をオープンするための処理を行うオープン手段と、前記オープン手段により前記接続処理に失敗したポート番号のポートのオープンに成功した場合、当該ポート番号を利用して他の通信装置と通信する通信手段と、前記オープン手段により前記接続処理に失敗したポート番号のポートのオープンに失敗した場合、前記制御手段による制御を再開させる再開手段と、を有する。   The communication device of the present invention includes a connection unit that performs a connection process for connecting to a predetermined port number of a communication interface, and, if the connection process by the connection unit is successful, the connection unit until the connection process by the connection unit fails Control means for controlling the connection means to perform the connection processing while switching the port number to be performed, and processing for opening the port number that failed in the connection processing in response to the failure of the connection processing. An opening means to perform, a communication means for communicating with another communication device using the port number when the opening of the port number for which the connection processing has failed by the opening means, and the connection by the opening means Resuming means for resuming control by the control means when opening of the port of the port number that has failed in processing has failed It has a.

本発明によれば、ポート番号の重複チェック機能の動作が明確でない状況においても、特定のポート番号が使用できるかどうかを確認することが可能になる。   According to the present invention, it is possible to confirm whether or not a specific port number can be used even in a situation where the operation of the port number duplication check function is not clear.

本発明の一実施形態に係わる通信装置のハードウェア構成の一例を示す図である。It is a figure which shows an example of the hardware constitutions of the communication apparatus concerning one Embodiment of this invention. 本発明の一実施形態に係わる通信装置の機能ブロック構成の一例を示す図である。It is a figure which shows an example of the functional block structure of the communication apparatus concerning one Embodiment of this invention. 本発明の一実施形態に係わる通信装置の動作フローを表すフローチャートである。It is a flowchart showing the operation | movement flow of the communication apparatus concerning one Embodiment of this invention. 本発明の一実施形態に係わる通信装置の動作を表すシーケンスチャートである。It is a sequence chart showing operation | movement of the communication apparatus concerning one Embodiment of this invention.

以下、本実施形態に係る通信装置について、図面を参照しながら詳細に説明する。   Hereinafter, the communication apparatus according to the present embodiment will be described in detail with reference to the drawings.

図1は、本実施形態における通信装置100のハードウェア構成図である。   FIG. 1 is a hardware configuration diagram of a communication device 100 according to the present embodiment.

表示部101はユーザに対する各種表示を行う。操作部で102は、通信装置100をユーザが操作するための操作ボタン、スイッチ等を有する。表示部101、操作部102は、タッチパネルにより構成することもできる。記憶部103は無線通信ネットワーク情報、データ送受信情報、通信機器情報など各種データを記憶、管理する。電源部104は通信装置100の各部に電力を供給し、外部電源からの電力、内蔵バッテリの電力を供給する。時計部105は時間を計測する。制御部106はROM107、RAM108に記憶される制御プログラムに従って通信装置100を制御する。ROM107は制御命令つまりコンピュータプログラムが格納されている。RAM108は制御部106のワークエリアとして利用される。制御部106はROM107、RAM108に記憶される制御プログラムを実行することにより、後述の図3、図4の説明での各部を構成する。   The display unit 101 performs various displays for the user. The operation unit 102 includes operation buttons, switches, and the like for the user to operate the communication apparatus 100. The display unit 101 and the operation unit 102 can also be configured by a touch panel. The storage unit 103 stores and manages various data such as wireless communication network information, data transmission / reception information, and communication device information. The power supply unit 104 supplies power to each unit of the communication device 100, and supplies power from an external power source and power of the built-in battery. The clock unit 105 measures time. The control unit 106 controls the communication device 100 according to a control program stored in the ROM 107 and RAM 108. The ROM 107 stores control instructions, that is, computer programs. The RAM 108 is used as a work area for the control unit 106. The control unit 106 executes each control program stored in the ROM 107 and the RAM 108, thereby constituting each unit in the description of FIGS.

アンテナ111は無線LAN通信を行うためのアンテナである。無線LANアンテナ制御部109はアンテナ111を制御する。通信インタフェース部(通信IF)110はネットワークの検索、構築、接続、管理など通信処理を行う。なお、本実施形態では、通信IF110はIEEE802.11規格準拠の無線LANインタフェースとして説明する。   The antenna 111 is an antenna for performing wireless LAN communication. The wireless LAN antenna control unit 109 controls the antenna 111. The communication interface unit (communication IF) 110 performs communication processing such as network search, construction, connection, and management. In the present embodiment, the communication IF 110 is described as a wireless LAN interface compliant with the IEEE 802.11 standard.

図2は、通信装置100を機能的に表した通信装置200の機能ブロック図である。   FIG. 2 is a functional block diagram of the communication device 200 that functionally represents the communication device 100.

通信装置200の機能ブロックは、ROM107にプログラムとして記憶され、制御部106によって実行されるソフトウェア構成である。なお、通信端末の機能ブロックに含まれる一部乃至全部がハードウェア化されていてもよい。図2のブロック構成は一例であり、TCP処理部230とIP処理部240を1つのブロックで構成したり、TCP処理部230を複数のブロックに分散したりするなど、各ブロックの役割構成は図2の例示に限定されるものではない。   The functional block of the communication device 200 is a software configuration that is stored as a program in the ROM 107 and executed by the control unit 106. Part or all of the functional blocks of the communication terminal may be implemented as hardware. The block configuration of FIG. 2 is an example, and the role configuration of each block such as configuring the TCP processing unit 230 and the IP processing unit 240 as one block or distributing the TCP processing unit 230 into a plurality of blocks is illustrated in FIG. It is not limited to two examples.

サーバ処理部210は、通信相手である外部通信装置と通信を行う際のサーバ機能を実現する処理部である。後述する図3の処理は、サーバ処理部210の処理に含まれる。TCP処理部230は、TCP(Transmission Control Protocol)の通信処理を実現する処理部である。IP処理部240はIP(Internet Protocol)の通信処理を実現する処理部である。Socketインタフェース220はTCP処理部230、IP処理部240の通信プロトコル処理部に対するインタフェースを実現する。なお、本実施形態ではTCP処理部230およびIP処理部240はOS(オペレーションシステム)の一部として実装される。またサーバ処理部210は、アプリケーションとして実装される。Socketインタフェース220はアプリケーションとOSの間に位置するインタフェースである。   The server processing unit 210 is a processing unit that realizes a server function when communicating with an external communication device that is a communication partner. The process of FIG. 3 described later is included in the process of the server processing unit 210. The TCP processing unit 230 is a processing unit that implements a TCP (Transmission Control Protocol) communication process. The IP processing unit 240 is a processing unit that implements IP (Internet Protocol) communication processing. The Socket interface 220 implements an interface to the communication protocol processing unit of the TCP processing unit 230 and the IP processing unit 240. In the present embodiment, the TCP processing unit 230 and the IP processing unit 240 are mounted as part of an OS (operation system). The server processing unit 210 is implemented as an application. The Socket interface 220 is an interface located between the application and the OS.

図3は、通信装置100の制御部106がROM107、RAM108に記憶される制御プログラムを実行して実施され、無線LAN通信による外部通信装置との通信処理を開始した際の動作フローチャートである。通信装置100の制御部106は、図3の処理を実行し、オープンできたポート番号を使ってデータ通信を開始する。   FIG. 3 is an operation flowchart when the control unit 106 of the communication apparatus 100 executes a control program stored in the ROM 107 and RAM 108 and starts communication processing with an external communication apparatus by wireless LAN communication. The control unit 106 of the communication apparatus 100 executes the process of FIG. 3 and starts data communication using the port number that can be opened.

なお、図3の説明は制御部106が実施するものとして説明するが、図3の処理は通信インタフェース部(無線LANインタフェース部)110が実施してもよい。また、図3の処理は、図4で説明するように図2の機能ブロックが実施する処理でもある。   3 is described as being performed by the control unit 106, but the processing in FIG. 3 may be performed by the communication interface unit (wireless LAN interface unit) 110. Further, the processing in FIG. 3 is also processing performed by the functional block in FIG. 2 as described in FIG.

本処理を開始すると通信装置100の制御部106のアドレス取得部は、無線LANインタフェースに割り当てられたIPアドレスを取得する(S301)。続いて制御部106の設定部は、外部通信装置との通信で使用するポート番号(n)を仮に設定する(S302)。本実施例においては、まず所定のポート番号としてnを49152番に仮設定する。次に、制御部106の接続部はS301で取得したIPアドレスのS302で決めたポート番号宛にTCPの接続処理を試みる(S303)。制御部106の判定部は、TCPの接続処理が成功した場合(S304でYes)、通信装置100はポート番号nが使用できないものと判定する。そして、制御部106の切断部は、ポートnに対する接続を切断する(S305)。切断部がポートnに対する接続を切断した後、制御部106の設定部は接続対象とするポート番号を別のポート番号に変更し、該変更後のポート番号の使用を試みる。具体的には、nに1を加算し、新たなnの値を外部通信装置との通信で使用するポート番号(n)を仮に設定する(S306)。新たなnの値が設定値として定める最大値を超えなければ(S307でNo)、制御部106の接続部は再度S301で取得したIPアドレスのS306で加算したポート番号宛にTCPの接続処理を試みる(S303)。S306でnを加算した結果nの値が設定値として定める最大値を超える場合(S307でYes)、制御部106の設定部は、通信装置100は使用できるポート番号が存在しないと判断し、エラーとして(S308)本処理を終了する。   When this process is started, the address acquisition unit of the control unit 106 of the communication apparatus 100 acquires the IP address assigned to the wireless LAN interface (S301). Subsequently, the setting unit of the control unit 106 temporarily sets a port number (n) used for communication with the external communication device (S302). In this embodiment, first, n is temporarily set to 49152 as a predetermined port number. Next, the connection unit of the control unit 106 attempts TCP connection processing to the port number determined in S302 of the IP address acquired in S301 (S303). When the TCP connection process is successful (Yes in S304), the determination unit of the control unit 106 determines that the communication device 100 cannot use the port number n. Then, the disconnection unit of the control unit 106 disconnects the connection to the port n (S305). After the disconnecting unit disconnects the connection to the port n, the setting unit of the control unit 106 changes the port number to be connected to another port number and tries to use the port number after the change. Specifically, 1 is added to n, and a new port number (n) used for communication with the external communication device is set temporarily (S306). If the new value of n does not exceed the maximum value set as the set value (No in S307), the connection unit of the control unit 106 again performs TCP connection processing for the port number added in S306 of the IP address acquired in S301. Try (S303). As a result of adding n in S306, when the value of n exceeds the maximum value determined as a setting value (Yes in S307), the setting unit of the control unit 106 determines that there is no port number that can be used by the communication device 100, and an error (S308) This process is terminated.

S303の接続処理の結果、TCPの接続処理に失敗した場合(S304でNo)、制御部106の判定部はTCPの接続処理に失敗したポート番号nが使用可能であると判定する。そして、制御部106のポート制御部はTCPの接続処理に失敗したポート番号nを外部通信装置からの待ち受け用ポートとしてオープンする(S309)。オープン処理に成功した場合(S310でYes)、制御部106の通知部はオープンしたポート番号nを外部通信装置に通知して(S311)、本処理を成功終了する。本実施例では、通信装置100は無線LANインタフェースからポート番号nの情報を含んだマルチキャストパケットを送信することで、待ち受け用ポート番号nを外部装置に通知する。   If the TCP connection process fails as a result of the connection process in S303 (No in S304), the determination unit of the control unit 106 determines that the port number n that has failed in the TCP connection process can be used. Then, the port control unit of the control unit 106 opens the port number n for which the TCP connection process has failed as a standby port from the external communication device (S309). If the open process is successful (Yes in S310), the notification unit of the control unit 106 notifies the open port number n to the external communication device (S311), and the process is successfully completed. In the present embodiment, the communication apparatus 100 notifies the external apparatus of the standby port number n by transmitting a multicast packet including information of the port number n from the wireless LAN interface.

また、S309のオープン処理に失敗した場合は(S310でNo)、制御部106のポート制御部はープン処理に失敗したポート番号nが使用できないものと判定する。その後、制御部106の設定部はS303の接続処理に失敗した場合と同様に、別のポート番号の使用を試みる。   If the open process in S309 has failed (No in S310), the port control unit of the control unit 106 determines that the port number n for which the open process has failed cannot be used. After that, the setting unit of the control unit 106 tries to use another port number, similarly to the case where the connection process of S303 fails.

次に図4を用いて、通信装置100において、アプリケーションが待ち受けポートをオープンする際の動作フローの一例を示す。   Next, an example of an operation flow when an application opens a standby port in the communication apparatus 100 will be described with reference to FIG.

前提として、通信装置100のアプリケーション(サーバ処理部210)が処理を開始する前に、IP処理部240のアドレス割り当て処理により無線LANインタフェースにIPアドレス192.168.0.1が割り当てられる(S401)。また、TCP処理部230のポートオープン処理により上記IPアドレスの49152番ポートが既にオープンされている(S402)ものとする。なお、S401でIPアドレスを設定する方法はどのような方法であってもかまわない。例えばDHCP(Dynamic Host Configuration Protocol)を用いて設定しても良いし、ユーザ操作によって指定されたIPアドレスを設定しても良い。同様に、S402で49152番ポートをオープンする方法も、どのような方法であってもかまわない。例えばOSがオープンしたものでも良いし、他のアプリケーションがオープンしたものでも良い。また、アプリケーション(サーバ処理部210)とTCP処理部230間の通信、アプリケーション(サーバ処理部210)とIP処理部240間の通信は、Socketインタフェース220を介して行われる。   As a premise, before the application (server processing unit 210) of the communication apparatus 100 starts processing, the IP address 192.168.0.1 is assigned to the wireless LAN interface by the address assignment processing of the IP processing unit 240 (S401). . Further, it is assumed that port 49152 of the IP address has already been opened by the port opening process of the TCP processing unit 230 (S402). Note that any method may be used to set the IP address in S401. For example, it may be set using DHCP (Dynamic Host Configuration Protocol), or an IP address specified by a user operation may be set. Similarly, any method may be used for opening the port 49152 in S402. For example, the OS may be opened, or another application may be opened. Further, communication between the application (server processing unit 210) and the TCP processing unit 230 and communication between the application (server processing unit 210) and the IP processing unit 240 are performed via the Socket interface 220.

上記前提の状態で、アプリケーション(サーバ処理部210)が接続待ち受け処理を開始すると(S403)、アプリケーションはOSのIP処理部240に対し、OSから無線LANインタフェースに割り当てられたIPアドレスの通知を要求する(S404)。OSのIP処理部240は、アプリケーション(サーバ処理部210)に無線LANインタフェースに割り当てられたIPアドレスを通知することにより、アプリケーションは無線LANインタフェースに割り当てられたIPアドレスを取得する(S405)。   When the application (server processing unit 210) starts connection waiting processing in the above-described state (S403), the application requests the OS IP processing unit 240 to notify the IP address assigned to the wireless LAN interface from the OS. (S404). The IP processing unit 240 of the OS notifies the application (server processing unit 210) of the IP address assigned to the wireless LAN interface, so that the application acquires the IP address assigned to the wireless LAN interface (S405).

続いてアプリケーション(サーバ処理部210)は、OSのTCP処理部230に対して、S405で取得したIPアドレスの49152番ポート宛にTCPの接続を試みる(S406)。S402ですでに49152番ポートはオープンしているので、S406の接続処理は成功し、接続処理に成功したことがTCP処理部230からアプリケーション(サーバ処理部210)に通知される(S407)。アプリケーション(サーバ処理部210)はS407の通知を受けて、49152番ポートは使用できないと判断し、S406、S407で確立した接続を切断する(S408、S409)。続いてアプリケーション(サーバ処理部210)は、ポート番号を変更し(図3のS306、S307)、新ポート番号を49153番にする。そして、TCP処理部230に対して、S405で取得したIPアドレスの49153番ポート宛に、TCPの接続を試みる(S410)。   Subsequently, the application (server processing unit 210) attempts TCP connection to the TCP processing unit 230 of the OS addressed to the port 49152 of the IP address acquired in S405 (S406). Since port 49152 has already been opened in S402, the connection processing in S406 has been successful, and the TCP processing unit 230 notifies the application (server processing unit 210) that the connection processing has been successful (S407). Upon receiving the notification in S407, the application (server processing unit 210) determines that port 49152 cannot be used, and disconnects the connection established in S406 and S407 (S408 and S409). Subsequently, the application (server processing unit 210) changes the port number (S306 and S307 in FIG. 3) and sets the new port number to 49153. Then, TCP connection is attempted to the TCP processing unit 230 to the 49153 port of the IP address acquired in S405 (S410).

通信装置100において49153番ポートはまだ使用されていないので(オープンされていない状態)、S410の接続処理は失敗し、TCP処理部230は接続失敗をアプリケーション(サーバ処理部210)に通知する(S411)。アプリケーション(サーバ処理部210)はS411の通知を受けて、49153番ポートが使用できると判断し、TCP処理部230に対して、49153番ポートのオープンを試みる(S412)。OSのTCP処理部230はS412の要求を受けて49153番ポートをオープンし、処理の結果(成功)をアプリケーション(サーバ処理部210)に通知する(S414)。   Since port 49153 is not yet used in communication device 100 (not opened), the connection process in S410 fails, and TCP processing unit 230 notifies the application (server processing unit 210) of the connection failure (S411). ). Upon receiving the notification in S411, the application (server processing unit 210) determines that the port 49153 can be used, and tries to open the port 49153 to the TCP processing unit 230 (S412). The TCP processing unit 230 of the OS receives the request of S412 and opens port 49153, and notifies the application (server processing unit 210) of the processing result (success) (S414).

アプリケーション(サーバ処理部210)はポートのオープンに成功すると、オープンしたポート番号を外部通信装置に通知する(S415)。ポート番号の外部通信装置への通知は、アプリケーション(サーバ処理部210)からの指示に従い、TCP処理部230、IP処理部240の通知のためのプロトコルデータを通信フレームに追加する。そして、プロトコルデータの追加後に、通信インタフェース部110を介して通信相手である外部通信装置に送信される。   When the application (server processing unit 210) succeeds in opening the port, the application (server processing unit 210) notifies the opened communication port number to the external communication device (S415). For notification of the port number to the external communication device, protocol data for notification from the TCP processing unit 230 and the IP processing unit 240 is added to the communication frame in accordance with an instruction from the application (server processing unit 210). Then, after the protocol data is added, the data is transmitted to the external communication device that is the communication partner via the communication interface unit 110.

S415の通知を受けて、外部通信装置は接続先のポート番号(49153番)を認識する。外部通信装置はS415で受信したポート番号にTCPの接続を行う(S416)。通信装置100は、通信インタフェース部110を介して受信したパケットをIP処理部240、TCP処理部230で順に処理する。そして、接続を受け入れたことをTCP処理部230がアプリケーション(サーバ処理部210)に通知することで外部通信装置とのポート番号(49153番)を利用した接続が行われる(S416)。   Upon receiving the notification in S415, the external communication device recognizes the connection destination port number (number 49153). The external communication apparatus performs TCP connection to the port number received in S415 (S416). The communication device 100 sequentially processes the packets received via the communication interface unit 110 by the IP processing unit 240 and the TCP processing unit 230. Then, the TCP processing unit 230 notifies the application (server processing unit 210) that the connection has been accepted, so that the connection using the port number (49153) with the external communication device is performed (S416).

これ以降通信装置100と外部通信装置間でデータ通信(S417)が可能になる。   Thereafter, data communication (S417) becomes possible between the communication device 100 and the external communication device.

以上が本発明の代表的な実施形態の一例であるが、本発明は、上記及び図面に示す実施形態に限定することなく、その要旨を変更しない範囲内で適宜変形して実施できるものである。   The above is an example of a typical embodiment of the present invention, but the present invention is not limited to the embodiment described above and shown in the drawings, and can be appropriately modified and implemented without departing from the scope of the present invention. .

上記実施形態において、通信装置100は無線LANインタフェースを用いて外部通信装置と通信するものとしたが、本発明はこれを限定するものではない。例えば通信装置100は有線LANのインタフェースも具備し、有線LANのインタフェースを用いて外部通信装置と通信するものとしても良い。その場合、図3に示すS301、S303、S309、S311の各処理は、すべて有線LANインタフェースに対して実行される。   In the above embodiment, the communication apparatus 100 communicates with an external communication apparatus using a wireless LAN interface, but the present invention is not limited to this. For example, the communication device 100 may include a wired LAN interface and communicate with an external communication device using the wired LAN interface. In that case, all the processes of S301, S303, S309, and S311 shown in FIG. 3 are executed for the wired LAN interface.

また、上記実施形態においては、外部通信装置と通信するインタフェースのIPアドレスを取得し(S301)、取得したIPアドレスに対して接続を試みる(S303)としたが、接続を試みる宛先アドレスはループバックアドレスでも良い。   In the above embodiment, the IP address of the interface that communicates with the external communication device is acquired (S301), and the connection to the acquired IP address is attempted (S303). It can be an address.

また、上記実施形態において接続を試みるポート番号(n)の初期値を49152としたが、本発明はこれを限定するものではない。ポート番号の仕様として規定される範囲の値であれば、任意の値をnの初期値としてかまわない。   In the above embodiment, the initial value of the port number (n) to be connected is 49152, but the present invention is not limited to this. An arbitrary value may be used as the initial value of n as long as the value is within the range defined as the port number specification.

また、ポート番号が使用できないと判断した後、次に接続を試みるポート番号はnに1を加えた値であるとし(S306)、nが設定値を超えるまで接続処理を繰り返すものとしたが、本発明はこれを限定するものではない。例えば、S306で指定する次に接続を試みるポート番号は、一定範囲内でランダムに決定されるものでも良い。また、S307で示す終了条件は、例えばS303の接続処理を試行した回数で判定しても良いし、図3の処理を開始してからの経過時間を基に判定するとしても良い。   Further, after determining that the port number cannot be used, the port number to be next connected is assumed to be a value obtained by adding 1 to n (S306), and the connection process is repeated until n exceeds the set value. The present invention is not limited to this. For example, the port number to be connected next specified in S306 may be determined randomly within a certain range. The termination condition shown in S307 may be determined based on the number of times the connection process in S303 has been tried, or may be determined based on the elapsed time since the process in FIG. 3 was started.

また、オープンに成功したポート番号nを外部通信装置に通知する際(S311)、通信装置100は無線LANインタフェースからマルチキャストパケットを送信することでこれを通知するとしたが、本発明はこれを限定するものではない。例えば、ブロードキャストパケットやユニキャストパケットで通知してもかまわない。さらには無線LAN以外のインタフェース(赤外線通信、Bluetooth(商標登録)、NFC(Near Field Communication)、3GPPが策定する携帯電話通信方式(3G、LTE)など)を用いて通知するとしてもかまわない。   Further, when the port number n that has been successfully opened is notified to the external communication device (S311), the communication device 100 notifies this by transmitting a multicast packet from the wireless LAN interface. However, the present invention limits this. It is not a thing. For example, it may be notified by a broadcast packet or a unicast packet. Further, the notification may be performed using an interface other than the wireless LAN (infrared communication, Bluetooth (registered trademark), NFC (Near Field Communication), 3GPP mobile phone communication system (3G, LTE), etc.).

(その他の実施例)
また、本発明は、以下の処理を実行することによっても実現される。即ち、上述した実施形態の機能を実現するソフトウェア(プログラム)を、ネットワーク又は各種記憶媒体を介してシステム或いは装置に供給し、そのシステム或いは装置のコンピュータ(またはCPUやMPU等)がプログラムを読み出して実行する処理である。
(Other examples)
The present invention can also be realized by executing the following processing. That is, software (program) that realizes the functions of the above-described embodiments is supplied to a system or apparatus via a network or various storage media, and a computer (or CPU, MPU, or the like) of the system or apparatus reads the program. It is a process to be executed.

100 本発明を実施する通信装置
101 表示部
102 操作部
103 記憶部
104 電源部
105 時計部
116 制御部
107 ROM
108 RAM
109 無線LANアンテナ制御部
110 通信インタフェース部
111 無線LANアンテナ
DESCRIPTION OF SYMBOLS 100 Communication apparatus which implements this invention 101 Display part 102 Operation part 103 Memory | storage part 104 Power supply part 105 Clock part 116 Control part 107 ROM
108 RAM
109 Wireless LAN Antenna Control Unit 110 Communication Interface Unit 111 Wireless LAN Antenna

Claims (9)

通信装置であって、
他の通信装置との通信を開始する際に、当該通信で利用するポート番号を選択するために、通信インタフェースの所定のポート番号に接続する接続処理を行う接続手段と、
前記接続手段による前記接続処理が成功した場合、前記接続手段による前記接続処理が失敗するまで、接続するポート番号を切替えながら、前記接続手段が前記接続処理を行うように制御する制御手段と、
前記接続処理が失敗したことに応じて、当該接続処理に失敗したポート番号のポートをオープンするための処理を行うオープン手段と、
前記オープン手段により前記接続処理に失敗したポート番号のポートのオープンに成功した場合、当該ポート番号を利用して前記他の通信装置と通信する通信手段と、
前記オープン手段により前記接続処理に失敗したポート番号のポートのオープンに失敗した場合、前記制御手段による制御を再開させる再開手段と、
を有することを特徴とする通信装置。
A communication device,
A connection means for performing connection processing for connecting to a predetermined port number of the communication interface in order to select a port number used in the communication when starting communication with another communication device ;
Control means for controlling the connection means to perform the connection process while switching the port number to be connected until the connection process by the connection means fails when the connection process by the connection means is successful;
An open means for performing processing for opening the port of the port number for which the connection processing has failed in response to the failure of the connection processing;
Successful open port of the connection process failed port by the open means, communication means for communicating with the other communication apparatus by using the port number,
A resuming means for resuming control by the control means when opening of the port of the port number for which the connection processing has failed by the open means;
A communication apparatus comprising:
前記オープン手段によるオープンに成功した場合に、当該ポート番号を前記他の通信装置に通知する通知手段を更に有することを特徴とする請求項1に記載の通信装置。   The communication apparatus according to claim 1, further comprising notification means for notifying the other communication apparatus of the port number when the opening by the opening means is successful. 前記接続手段は、前記通信インタフェースに割り当てられたアドレスに前記接続処理を行うことを特徴とする請求項1または2に記載の通信装置。   The communication apparatus according to claim 1, wherein the connection unit performs the connection process on an address assigned to the communication interface. 前記接続手段は、ループバックアドレスに前記接続処理を行うことを特徴とする請求項1または2に記載の通信装置。   The communication apparatus according to claim 1, wherein the connection unit performs the connection process on a loopback address. 前記接続処理は、TCP(Transmission Control Protocol)に準拠した接続処理であることを特徴とする請求項1から4のいずれか1項に記載の通信装置。   5. The communication apparatus according to claim 1, wherein the connection process is a connection process compliant with TCP (Transmission Control Protocol). 6. 前記接続手段が、所定の範囲のポート番号の各々に対する前記接続処理に失敗しなかった場合、前記制御手段は処理をエラー終了することを特徴とする請求項1から5のいずれか1項に記載の通信装置。   6. The control unit according to claim 1, wherein if the connection unit does not fail in the connection process for each port number within a predetermined range, the control unit terminates the process with an error. 6. Communication equipment. 前記接続手段が、所定時間内に前記接続処理に失敗しなかった場合、前記制御手段は処理をエラー終了することを特徴とする請求項1から5のいずれか1項に記載の通信装置。   The communication apparatus according to claim 1, wherein if the connection unit does not fail the connection process within a predetermined time, the control unit ends the process with an error. 通信装置の制御方法であって、
他の通信装置との通信を開始する際に、当該通信で利用するポート番号を選択するために、通信インタフェースの所定のポート番号に接続する接続処理を行う接続工程と、
前記接続処理が成功した場合、前記接続処理が失敗するまで、接続するポート番号を切替えながら、前記接続処理を行うように制御する制御工程と、
前記接続処理が失敗したことに応じて、当該接続処理に失敗したポート番号をオープンするための処理を行うオープン工程と、
前記オープン工程において、前記接続処理に失敗したポート番号のポートのオープンに成功した場合、当該ポート番号を利用して前記他の通信装置と通信する通信工程と、
前記オープン工程において、前記接続処理に失敗したポート番号のポートのオープンに失敗した場合、前記制御工程における制御を再開させる再開工程と、
を有することを特徴とする制御方法。
A communication device control method comprising:
A connection step of performing connection processing for connecting to a predetermined port number of the communication interface in order to select a port number to be used in the communication when starting communication with another communication device ;
If the connection process is successful, a control step for controlling the connection process while switching the port number to be connected until the connection process fails,
In response to the failure of the connection process, an open step of performing a process for opening a port number that has failed in the connection process;
In the open process, if successfully opened the ports of the failed port number to the connection processing, and a communication step of using the port number for communicating with the other communication apparatus,
In the opening step, when opening of the port of the port number that failed in the connection process has failed, a resuming step of resuming control in the control step;
A control method characterized by comprising:
コンピュータを請求項1から7のいずれか1項に記載の通信装置として動作させるためのプログラム。   The program for operating a computer as a communication apparatus of any one of Claim 1 to 7.
JP2012060234A 2012-03-16 2012-03-16 Communication device control method and communication device Active JP6061480B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012060234A JP6061480B2 (en) 2012-03-16 2012-03-16 Communication device control method and communication device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012060234A JP6061480B2 (en) 2012-03-16 2012-03-16 Communication device control method and communication device

Publications (2)

Publication Number Publication Date
JP2013196122A JP2013196122A (en) 2013-09-30
JP6061480B2 true JP6061480B2 (en) 2017-01-18

Family

ID=49395048

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012060234A Active JP6061480B2 (en) 2012-03-16 2012-03-16 Communication device control method and communication device

Country Status (1)

Country Link
JP (1) JP6061480B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015870B (en) 2016-09-19 2020-11-03 创新先进技术有限公司 Method and device for realizing communication between web page and local application and electronic equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2679613B2 (en) * 1994-03-16 1997-11-19 日本電気株式会社 Network address automatic setting circuit
JP2002189693A (en) * 2000-12-21 2002-07-05 Sharp Corp Job processing result communication system and computer used for the system
JP3797344B2 (en) * 2002-10-11 2006-07-19 オンキヨー株式会社 Server client system

Also Published As

Publication number Publication date
JP2013196122A (en) 2013-09-30

Similar Documents

Publication Publication Date Title
JP6335629B2 (en) Communication apparatus, control method, and program
WO2013177001A1 (en) Devices and methods for facilitating direct pairing in a wireless docking system
WO2013130502A1 (en) Shared network access via a peer-to-peer link
WO2018036071A1 (en) Method and device for networking devices
JP6530634B2 (en) INFORMATION PROCESSING APPARATUS, CONTROL METHOD THEREOF, AND PROGRAM
EP3763164B1 (en) Electronic device supporting multiple wireless communication protocols and method therefor
CN103974376A (en) Network connection assisting system and method
KR20120025114A (en) Apparatus and method for determining validity of wifi connection in wireless communication system
EP2672758B1 (en) Methods and apparatuses for easing Internet access by mobile stations associated with a mobile access point
EP3182787A1 (en) Communication method and device
WO2018053894A1 (en) Internet-of-things access point handover method and device based on transmission rate
US9392537B2 (en) Terminal and connection method for same
KR101853398B1 (en) Method and system for registering server connection of IoT device using smartphone application
JP6061480B2 (en) Communication device control method and communication device
US20130107697A1 (en) Network Connection System of Network Electronic Device and Method to Solve Terminal Device Unable to Reach Electronic Device Caused by Router Not Supporting NAT Loopback
CN103781138A (en) Method, apparatus and system for connecting WiMo sending terminal to WLAN
KR20240043813A (en) Authorization, creation, and management of private networks
CN105681480A (en) Point-to-point protocol (PPP) dial on demand method and equipment
US20200344668A1 (en) Non-transitory computer-readable recording medium storing computer-readable instructions for communication device, communication device, and method executed by communication device
US9602579B2 (en) Communication apparatus, method for controlling the same, and program
JP2013131993A (en) Radio access point device, radio access point connection method, and radio access point connection program
JP5246029B2 (en) Wireless communication system
JP5812065B2 (en) External storage device, data file transmission / reception system, data file transmission / reception method / program
CN112188593B (en) Wireless configuration method and device, storage medium and electronic device
WO2023083174A1 (en) Subscription update method and device, network element, and medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20150316

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20160223

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20160301

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20160427

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20160823

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20160928

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20161115

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20161213

R151 Written notification of patent or utility model registration

Ref document number: 6061480

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151