Programming :: While Receiving Can Use Functions Like Strchr() To Differentiate These Fields For Sockets?
Apr 15, 2009
constructing a protocol where in it involves sending and receiving different files, so sending data over consists of file name, size of the file and content of the file, so while receiving can i use functions like strchr() to differentiate these fields for sockets? so to allocate memory for file to save i need to have its size.
I would like to send a data using one thread and receive a data using other thread by using a same socket connection using USD sockets. The calls i am using for sending and receiving are send(), recv(). let me know is it possible to send and receive the data parallel (Full duplex communication)?
I want to extract all the common entries in the given 3 columns(fields) in the file using awk::can somebody tell me how it can be done in awk...the file is::
ABD : 5869 events, relative ratio : 1.173800E-01 , sum of ratios : 1.173800E-01 VBD : 12147 events, relative ratio : 2.429400E-01 , sum of ratios : 3.603200E-01 SDF : 17000 events, relative ratio : 3.400000E-01 , sum of ratios : 7.003200E-01
I have a file with 200 000 lines and I want to append the fields of each line based on matching first field. The resulting file should have 70 000 columns but has "only" 18 000. The command I'm using is working perfectly with a smaller file, wich lead to 14 000 columns. Could there be a limit in number of fields that awk can handle ? Here's my awk command :
Code:
awk -F, 'END { for (k in _) print _[k] } { _[$1] = $1 in _ ? _[$1] FS $4 : $1","$4 } ' file > out
Also, this command writes ^M (windows line break) after each columns. Removing them is easy but where do they come from ? Working on Ubuntu 10.10
I have an array called @logons. How can I step thru the array and split the fields? This is what I have so far, but doesnt work. I got the feeling I the split statement syntax is incorrect.
Code:
print @logons; foreach my $logons(@logons){ ($userid, $ip) = split(',',$logons);
[code]....
Update: Appears the data in @logons has a column header from the mysql query which I used to populate it with. So that code which I was testing does indeed work.
I want to write a function which calculates the space needed between fields, to generate a table with aligned fields, like when you type "ls -l", the operating system generates a table with beautifully aligned fields. I've got this code so far:
Code:
for line in $(cat tmpSearch) do line=`echo $line | tr ":" " "`
i am reading a database flat file with the "awk" command which has 4 fields separated by colon ":" .I want to show the output of these fields in a certain way that every record is numbered e.g
Instead, it uses "setsockopt" to set some options.
My guess is that it is trying to send packets over the eth0 interface instead over the wl0 (wireless) interface (which is the one I want to use to send pings).
Now, my question is: Is there any other way to send pings in C by binding to an interface?
I am faced with the following problem; I need to update all fields of type datetime without ... with the following sort data:01-01-2010 12:10:30.256 - this is just an example.these fields are restricted with a unique constrained. My question is how can I generate the above sort data, especially the last three numbers with leading point. After that how can I update a table with existing data with this newly generated data so that the fields really do carry unique data.As you probably can read out of my question, I read through the help in pgAdmin and came as far as generating date, maybe datetime but not the .123 number. And a little insert script I found in the help, that I modified as UPDATE resulted in updating only the last generated data in all required fields.
I need to create a C/C++ program in Linux that succeeds in detecting how many tcp-sockets and what tcp-sockets are created by the other processes in the system in a particular time interval (e.g., the interval time this application is running in). Then, I'd need to get some information like local/remote port number and local/remote ip address of each of these sockets.
I am struggling a little on how to best approach this problem. I have wrote a server program that runs via xinetd, that obviously spits out data at the client end. Fairly straightforward stuff?There is a point in my server code where I need to display an image/gui i.e something that runs on X11 that prompts a user to perform a task on the display connected at the the server side.So far I have written a test program that displays some text at the client end and then launches the browser at the server end. I have also set the following export. Code: export DISPLAY=:0 and then goes on to launch my web browser. Works great when ran locally on the server and when I remotely telnet in to the server and run the code.
However when I try to run the same piece of code as a xinetd service the export seems to have zero affect and the client terminal window displays errors associated with there not being a X11 server running.The code launches fine when I create a socket to serverip:6556 it just the ability to display gui programs to another display that does not seem to be working.
Can someone help me with this problem,trying to send a packet,using tcp/ip,the packet should look like this:
Code: field 1: SOCKS protocol version, 1 byte (0x05 for this version) field 2: status, 1 byte: 0x00 = request granted 0x01 = general failure 0x02 = connection not allowed by ruleset 0x03 = network unreachable 0x04 = host unreachable 0x05 = connection refused by destination host 0x06 = TTL expired 0x07 = command not supported / protocol error 0x08 = address type not supported field 3: reserved, must be 0x00 field 4: address type, 1 byte: 0x01 = IPv4 address 0x03 = Domain name 0x04 = IPv6 address field 5: destination address of 4 bytes for IPv4 address 1 byte of name length followed by the name for Domain name 16 bytes for IPv6 address field 6: network byte order port number, 2 bytes and this is my code:
Code: int domainLen = strlen(domain); char reply[domainLen + 7]; reply[0] = 5; // version reply[1] = 0; // succed reply[2] = 0; // reserved reply[3] = 3; // its a domain reply[4] = domainLen;; // lenght of domain for(int j = 0; j < domainLen; ++j) { reply[j + 5] = domain[j]; } reply[5 + domainLen] = 80; // port reply[20] = '�'; Send(reply, sizeof(reply)); domain is "www.google.com". Am I doing it right ? I dont know much about bits.
I am doing a project where 2 clients connect to server and communicate (chat) and transfer data one after other using sockets. I have working code for this in C language. Now our main aim is to create a communication link where two clients transfer multiple streams data parallely. To be more precise i want to transfer images files and audio files parallel at same time, so is it possible to send data parallel using one socket connection?
I have a problem creating my second socket in client file. the program was running well but when I try to add another socket to connect to the same server, I got a problem connecting to the first socket! it doesn't make sense. the original code was:
I am using the API libpcap in order to filter the traffic of the port 53 from my PC ro other PCs, in other words the DNS traffic.I want to get more information about the DNS traffic that is being sent to the DNS server, in other words the queries. So far I have no idea how to read the information data or payload of the UDP package in order to read the content of the traffic for example if there is any PTR, A, MX, etc Resource Record.According to the RFC 1053 there is a header that is possible to use in order to easily get this info.
NextPendingConnection () returns a new socket with respect to a new client. This new QSocket is passed to the connect () function which connects it to a SLOT 'xyz' with SIGNAL 'readyRead()'. Now in the SLOT 'xyz' how I am supposed to automate the monitoring of ALL connected sockets to see whether some data is available on them? One pathetic way would be to run all the sockets through a for loop and check each one of them for the data. Secondly, I read up on QSocketNotifier() here: [URL]. But I am not sure if that is the correct thing.
I am coding a http server which has to send the file(s) such as images, .avi files, .mpeg, that the client is going to request. I have been trying of sending files through sockets.
I have a problem passing a file descriptor from one process to another.
I have two processes A and B. Both are running in different network and filesystem namespaces, so it is impossible to use unix domain sockets or net sockets to pass a file descriptor from process A to process B.
The usage of STREAMS is also impossible, as you can see in fixunix.com/unix/84093-streams-pipes-ioctl-i_sendfd.html
[quotation begin] Linux doesn't have STREAMS, which are the System V way of doing this task. ... [quotation end]
Are there additional possibilities for file descriptor passing like using named pipes or something like that or does anybody know a good workaround for this problem ?
I have written a server application which has select for both incoming new client connection requests and incoming data from client. I am able to process incoming connection requests and client data.
For example, server has 8 clients connected to it. If client 3 disconnects from server, how will server come to know this client has disconnected and to close its client socket fd gracefully? Does server's select get data on that client socket fd as 'close' data or any error code in recv() function that notifies server to close this client socket fd? Also if client disconnects abruptly without sending close request to server, how should server handle this? Does server get "EPIPE" error?
None of my daemon scripts work now, and the startup process displayed errors. Should I reinstall the OS and start from scratch, or is there a way to recover these files? Is there a way to rebuild the files I deleted?
Iam using socket programming in one of my problem. The scenario is like this.
=>one module is working as a socket server(process p1) is able to handle client sockets on that port. =>one module is working as socket client (process p2) is connected to server socket and Tx/Rx data on this socket. This module has some more threads, based on received data from server socket it will connect to http on other thread and get information... =>one more module is working as socket client (process p3) is also connected to server socket and doing some other transactions.
Here my problem is when in presence of p2, p3 http connection taking more time than the expected. If we wont start p3(means only one server-client socket) then http connection is fast enough.
I'm trying to send an image (which can vary in file size) from a python server to an android client . I'm not getting any errors and the file is being created client side however it always seems to fall short of the total file size. I have tried many different options in regards to input streams and buffer sizes but I have had no luck.
I am trying to create a socket server in user space and a client in kernel space and send big messages (a little over 64kbytes) between them.
I used an kernel socket programming examplefrom this link - url for the kernel client side.
When the client in kernel side sends out a 64k message, usually, the server side in the user space will get a big part of the message, but will stuck at waiting for the recv() to return to get the rest of it. So I am chopping the packets into small pieces, 1000 bytes each to send to the server. But only some times, the packets will all arrive at the server/receiver side, and the server and assemble the whole message. Many times, the server is stuck at waiting for the last a couple of byte from the sending side. From the sending side printk log, it has already sent every thing.
I am attaching some log here, and the code at the end. Can someone give me some idea on how to force the data to arrive at the receiver side? Maybe the kernel on the receiver side is holding part of the packet so the receiver program in the user space is blocked at recv()? I tried adding TCP_NODELAY on sockets on both sender and receiver sides, both it did not help.
I got a connection from (10.16.216.217 , 1489) - Server side stuck on recv()- bytes_recieved 17384 bytes_recieved 32768, total received 50152, expected 65540 - Client side is already done - code....