
socket_create_listen 함수는 주소와 포트를 직접 입력하거나, 변수에 저장한 값을 사용할 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$address = '127.0.0.1';
$port = 8080;
$sock = socket_create_listen($port);
또는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$address = '127.0.0.1';
$port = 8080;
$sock = socket_create_listen($address, $port);
하지만, 다음과 같이 사용하는 것은 권장되지 않습니다.
#hostingforum.kr
php
$address = '127.0.0.1';
$port = 8080;
$sock = socket_create_listen($address . ':' . $port);
이 방법은 주소와 포트를 하나의 문자열로 합쳐서 입력하는 방식입니다. 하지만, socket_create_listen 함수는 주소와 포트를 분리하여 입력하는 것을 권장합니다.
따라서, 두 번째 예제와 같이 주소와 포트를 분리하여 입력하는 것이 좋습니다.
2025-07-23 21:00