I have a text file which represents a http flow like this:
I need to count characters (bytes) in packet payloads. I noticed that if a packet has a payload this is after a blank line following the headers. It is possible that a new header is attached to a preceding packet as shown in the example. I need an output like this:
I have a flat file and need to count no of records in the file less the header and the trailer record.
I would appreciate any and all asistance
Thanks
Hadi Lalani (2 Replies)
Hi,
I have a pipe seperated file
I want to write a code to display count of lines that have 20th field not null.
nawk -F"|" '{if ($20!="") print NR,$20}' xyz..txt
This displays records with 20th field also null.
I would like output as: (4 Replies)
Hey all,
I'm looking for a command that will search a directory (and all subdirectories) and give me a file count for the number of files that contain specific characters within its filename. e.g. I want to find the number of files that contain "-a.jpg" in their name.
All the searching I've... (6 Replies)
Hi everyone.
I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this:
ID: 20
Name: X
Age: 19
ID: 21
Name: Z
ID: 22
Email: xxx@yahoo.com
Name: Y
Age: 19
I want to grep records that... (4 Replies)
Hi,
I have a huge file containing thousands of records which are of following pattern:
TYPE1
{
originNodeType : "IVR"
originHostName : "AAIVR"
originTransactionID : "01310559"
originTimeStamp : "20110620192440+0530"
hostName : "hhhh"
voucher : '0'D
rProfileID : "ZZZZ"
Before
{... (5 Replies)
sed -e "s// /g" old.txt > new.txt
While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes.
Is there a search for that? I tried cut but couldn't get it to work.
Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Hi all, I need help.
I have an input text file (input.txt) like this:
21 GTGCAACACCGTCTTGAGAGG 50
21 GACCGAGACAGAATGAAAATC 73
21 CGGGTCTGTAGTAGCAAACGC 108
21 CGAAAAATGAACCCCTTTATC 220
21 CGTGATCCTGTTGAAGGGTCG 259
Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Hi ,
I have a requirement to read a file ( 5 fields , ~ delimited) and find the records which contain anything other than Alphabets, Numbers , comma ,space and dot . ie a-z and A-Z and 0-9 and . and " " and , in 2nd field. Once I do that i would want the result to have field1|<flag>
flag can... (2 Replies)
Discussion started by: ashwin3086
2 Replies
LEARN ABOUT PHP
socket_recv
SOCKET_RECV(3) 1 SOCKET_RECV(3)socket_recv - Receives data from a connected socketSYNOPSIS
int socket_recv (resource $socket, string &$buf, int $len, int $flags)
DESCRIPTION
The socket_recv(3) function receives $len bytes of data in $buf from $socket. socket_recv(3) can be used to gather data from connected
sockets. Additionally, one or more flags can be specified to modify the behaviour of the function.
$buf is passed by reference, so it must be specified as a variable in the argument list. Data read from $socket by socket_recv(3) will be
returned in $buf.
PARAMETERS
o $socket
- The $socket must be a socket resource previously created by socket_create().
o $buf
- The data received will be fetched to the variable specified with $buf. If an error occurs, if the connection is reset, or if no
data is available, $buf will be set to NULL.
o $len
- Up to $len bytes will be fetched from remote host.
o $flags
- The value of $flags can be any combination of the following flags, joined with the binary OR ( |) operator.
Possible values for $flags
+-------------+---------------------------------------------------+
| Flag | |
| | |
| | Description |
| | |
+-------------+---------------------------------------------------+
| | |
| MSG_OOB | |
| | |
| | Process out-of-band data. |
| | |
| | |
| MSG_PEEK | |
| | |
| | Receive data from the beginning of the receive |
| | queue without removing it from the queue. |
| | |
| | |
|MSG_WAITALL | |
| | |
| | Block until at least $len are received. However, |
| | if a signal is caught or the remote host discon- |
| | nects, the function may return less data. |
| | |
| | |
|MSG_DONTWAIT | |
| | |
| | With this flag set, the function returns even if |
| | it would normally have blocked. |
| | |
+-------------+---------------------------------------------------+
RETURN VALUES socket_recv(3) returns the number of bytes received, or FALSE if there was an error. The actual error code can be retrieved by calling
socket_last_error(3). This error code may be passed to socket_strerror(3) to get a textual explanation of the error.
EXAMPLES
Example #1
socket_recv(3) example
This example is a simple rewrite of the first example from "Examples" to use socket_recv(3).
<?php
error_reporting(E_ALL);
echo "<h2>TCP/IP Connection</h2>
";
/* Get the port for the WWW service. */
$service_port = getservbyname('www', 'tcp');
/* Get the IP address for the target host. */
$address = gethostbyname('www.example.com');
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "
";
} else {
echo "OK.
";
}
echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
echo "socket_connect() failed.
Reason: ($result) " . socket_strerror(socket_last_error($socket)) . "
";
} else {
echo "OK.
";
}
$in = "HEAD / HTTP/1.1
";
$in .= "Host: www.example.com
";
$in .= "Connection: Close
";
$out = '';
echo "Sending HTTP HEAD request...";
socket_write($socket, $in, strlen($in));
echo "OK.
";
echo "Reading response:
";
$buf = 'This is my buffer.';
if (false !== ($bytes = socket_recv($socket, $buf, 2048, MSG_WAITALL))) {
echo "Read $bytes bytes from socket_recv(). Closing socket...";
} else {
echo "socket_recv() failed; reason: " . socket_strerror(socket_last_error($socket)) . "
";
}
socket_close($socket);
echo $buf . "
";
echo "OK.
";
?>
The above example will produce something like:
<h2>TCP/IP Connection</h2>
OK.
Attempting to connect to '208.77.188.166' on port '80'...OK.
Sending HTTP HEAD request...OK.
Reading response:
Read 123 bytes from socket_recv(). Closing socket...HTTP/1.1 200 OK
Date: Mon, 14 Sep 2009 08:56:36 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT
ETag: "b80f4-1b6-80bfd280"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
OK.
PHP Documentation Group SOCKET_RECV(3)