steyrblade
Mitglied
Hallo
ich habe gerade ein Problem mit einer Socket-Verbindung.
Ich bekomme immer eine unterschiedliche Anzahl von leeren
Zeilen (die nicht vorhanden sind), vor und nach den eigentlichen Daten die ich einlesen möchte.
URL und Port logischerweise mit gesendet.
Als Ausgabe bekomme ich dann z.B. :
Ausgabe von $data:
Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] =>
[9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] =>
[18] => [19] => [20] => [21] => [22] => [23] => [24] => [25] => [26]
=> [27] => [28] => [29] => [30] => [31] => [32] => [33] => [34] =>
[35] => [36] => [37] => [38] => [39] => [40] => [41] => [42] => [43]
=> [44] => [45] => [46] => [47] => [48] => [49] => [50] => [51] =>
[52] => [53] => [54] => [55] => [56] => [57] => [58] => [59] => [60]
=> [61] => [62] => [63] => [64] => [65] => [66] => [67] => [68] =>
[69] => [70] => [71] => [72] => [73] => [74] => [75] => [76] => [77]
=> [78] => [79] => [80] => [81] => [82] => [83] => [84] => [85] =>
[86] => [87] => [88] => [89] => [90] => [91] => [92] => [93] => [94]
=> [95] => [96] => [97] => [98] => [99] => [100] => [101] => [102] =>
[103] => [104] => [105] => [106] => [107] => [108] => [109] => [110]
=> HTTP/1.1 200 OK [111] => Date: Mon, 27 Apr 2009 14:34:03 GMT [112]
=> Server: Apache/2.2.3 (CentOS) [113] => Last-Modified: Mon, 27 Apr
2009 14:24:51 GMT [114] => ETag: "561a4f-21b4-1bfa32c0"
...
Leerzeilen kommen oft auch am Ende vor.
Kann mir da jemand weiterhelfen?
Danke schon mal
ich habe gerade ein Problem mit einer Socket-Verbindung.
Ich bekomme immer eine unterschiedliche Anzahl von leeren
Zeilen (die nicht vorhanden sind), vor und nach den eigentlichen Daten die ich einlesen möchte.
URL und Port logischerweise mit gesendet.
PHP:
$url = "http://xyz.com/asci_ausgabe.html";
$port ="7779";
function verbindung($url,$port)
{
error_reporting(0);
$url = str_replace("http://","",$url);
$urlComponents = explode("/",$url);
$domain = $urlComponents[0];
$resourcePath = str_replace($domain,"",$url);
$socketConnection = fsockopen($domain, $port, $errno, $errstr);
if (!$socketConnection)
{
return 0;
}
else
{
$data = '';
@fputs($socketConnection, "GET $resourcePathHTTP/1.0\r\nHost:$domain\r\n\r\n");
while (!feof($socketConnection))
{
$data[] =fgets($socketConnection);
}
fclose ($socketConnection);
return($data);
}
}
Als Ausgabe bekomme ich dann z.B. :
Ausgabe von $data:
Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] =>
[9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] =>
[18] => [19] => [20] => [21] => [22] => [23] => [24] => [25] => [26]
=> [27] => [28] => [29] => [30] => [31] => [32] => [33] => [34] =>
[35] => [36] => [37] => [38] => [39] => [40] => [41] => [42] => [43]
=> [44] => [45] => [46] => [47] => [48] => [49] => [50] => [51] =>
[52] => [53] => [54] => [55] => [56] => [57] => [58] => [59] => [60]
=> [61] => [62] => [63] => [64] => [65] => [66] => [67] => [68] =>
[69] => [70] => [71] => [72] => [73] => [74] => [75] => [76] => [77]
=> [78] => [79] => [80] => [81] => [82] => [83] => [84] => [85] =>
[86] => [87] => [88] => [89] => [90] => [91] => [92] => [93] => [94]
=> [95] => [96] => [97] => [98] => [99] => [100] => [101] => [102] =>
[103] => [104] => [105] => [106] => [107] => [108] => [109] => [110]
=> HTTP/1.1 200 OK [111] => Date: Mon, 27 Apr 2009 14:34:03 GMT [112]
=> Server: Apache/2.2.3 (CentOS) [113] => Last-Modified: Mon, 27 Apr
2009 14:24:51 GMT [114] => ETag: "561a4f-21b4-1bfa32c0"
...
Leerzeilen kommen oft auch am Ende vor.
Kann mir da jemand weiterhelfen?
Danke schon mal