File pointer - what type is it?

Hello again,

$filePointer = fsockopen($this->_host, $this->_porto);

If we do:


what type do we get?

I’m asking this, because I cannot test it, since I don’t have access to a socket that will return nothing else then FALSE.

When I ask for the nature of $filePointer I’m getting answers about “what it’s used for”, and those are not the same.

I know that it’s used to mark a place where the reading or writing should start, but I would like to understand what type of thing is that. Hence, my question about var_dump;

From the PHP Manual about fsockopen. we can read:

fsockopen() returns a file pointer which may be used together with the other file functions

But I still can’t understand that type is that.

Thanks a lot,

Thanks. I’m unable to test, so get_resource_type is something that I cannot use unfortunately. However, I’ve found this nice appendix on the pages you have provided, that show us the mapping relations between the functions that use resources, and what type of resources they return. Here.

I found out that, the resource type of the File Pointer returned by fsockopen function is a: stream .

In the a quest search about stream meaning, I end up here:

a stream is a resource object which exhibits streamable behavior.

I have no idea what streamable means. But I believe is something to do with stream. :goof:

I read on, and I found something that I believe is related with streamable meaning:

it can be read from or written to in a linear fashion

So I asked what linear fashion could mean on this context… but if we read on…

and may be able to fseek() to an arbitrary locations within the stream.

So I lost all the linear concept I previously had.

I’m just trying to understand what I’m doing, in order to solve the problem in hands.

I’m not asking for a definition but, some words about it, can help me understand what a file pointer stream type resource object of a given socket, is. :eek:


You really need to set up some kind of port on which you can test, otherwise it will be difficult to write the code you need.

Could you not try to connect to port 80 on localhost (assuming you have a webserver running locally)? Not sure if this is possible, but it might allow you to test your connection…

I will try your suggestion.
No I don’t have a localhost running but I can arrange something in order to test it.

To really test this, I need to make a appointment with the server “owners”, and only at a given date and time I can test it. So, I’m trying to grab the maximum I can get, so that I can do all at once. :slight_smile:

No issues. I will manage a workaround of course. My biggest problem is, as always, the basics that any programmer may have and I don’t. Like, what is a socket and a stream and so on…

Need to dig in a bit more.

Thanks a lot,

A resource, see [fphp]get_resource_type/fphp too. :wink: