fsockopen trouble

Discussion in 'PHP' started by matthewrobertbell, Jan 3, 2008.

  1. #1
    I'm quite new to sockets, I'm using fsockopen to communicate with a server. What i want to do is communicate with a server get a response back then communicate again and get another response back. The first exchange goes fine but the second doesnt seem to work?

    Code:
    
    //$fp is a valid socket, using fsockopen
    fwrite($fp, $socks_header);			
    print fread($fp, 2048);
    fwrite ($fp, $header);
    print fread($fp, 2048);
    
    PHP:
    Thanks
     
    matthewrobertbell, Jan 3, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    try to close the connection first after reading and then communicate again

    Regards

    Alex
     
    kmap, Jan 4, 2008 IP
  3. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The problem is that i need both communications to be in the same connection.
    I think the problem may be that it doesnt think that the first communication has finished?
     
    matthewrobertbell, Jan 4, 2008 IP