j_s_stack
j_s_stack

Reputation: 665

Do I need to Close a fsockopen Connection?

I just had a look on the PHP fsockopen Function and wondered if I have to Close the Connection after using it.

In the php.net manuel it said that it opens a connectionless Connection (?!?!), Background is just an easy external Linkchecker.

Do I need to close it? If yes how do I do that?

Upvotes: 1

Views: 5248

Answers (2)

user2289821
user2289821

Reputation: 78

http://php.net/manual/en/function.fsockopen.php

in every example it shows "fclose($fp);"

is that what you're asking?

Upvotes: 0

Barmar
Barmar

Reputation: 781721

Yes, you need to close it. You close it with fclose().

If you don't close it in your code, it will be closed automatically when the script exits.

Whether the socket has a connection or is connectionless depends on the type of socket. If it's a TCP socket there's a connection, if it's a UDP socket there's no connection, because UDP doesn't have connections. But this is irrelevant to whether you need to close it; even with a connectionless protocol, the emulates a connection by binding to a particular port number and receiving the data on that port.

Upvotes: 3

Related Questions