Programming :: Add Local Sockets In Multi-threaded Application In Order To Exchange Data Between Threads?
Jul 24, 2010
I'm trying to add local sockets in my multi-threaded application in order to exchange data between threads. The only problem I got is that most of the information available on the net is related to internet oriented socket programming whileI want to perform local connections. got a thread that does the sniffing via libpcap. And I would like that thread to send each captured packet to a second thread that will analyse the packetof the thread implementations is written in separate .h file.Or maybe there is a more effective method of exchanging data between threads
View 14 Replies
ADVERTISEMENT
Apr 20, 2011
I ran into an inconsistency in handling timers (VTALRM) between AMD and intel platforms with threads. My understanding was that the timers are per process. I discovered I must call setitimer in the thread on intel though. AMD allows me to make the setitimer call once in the main thread as expected. The code below demonstrates the issue. I must add the code in the INTEL define for it to work properly on intel cpu's. Am I missing something dumb??
[Code]...
View 4 Replies
View Related
Aug 12, 2010
For quite some time now, I've been trying to implement a multi-threaded or forked TCP server to perform the following action:1) Listen for new connections on all ip addresses on a specific port.2) Wait for a new connection to arrive3) When a new connection coms in, fork or thread to free up the listening process so it can go back to #2.When handling a client after it's been forked/threaded4) Get the connected client's ip address.5) Perform some in-house processing;6) Read the data sent from the client (checking for http connections)7) Perform some more processing;8) Write some data back to the client based on the above processing9) Close the socket/thread/forkI've tried implementing an solution similar to the multi-threaded example show here http://perl.active-venture.com/pod/p...-sockets.html; as well as looking at the CPAN solutions Net:aemon and POE::Component::Server::TCP but these don't seem to give me the information needed.The active-venture solution provides me with what I need, but randomly exits without reason/error and when attempting to change the 'for' loop to a 'while' loop, it keeps throwing up different errors.
View 2 Replies
View Related
Jun 15, 2010
writing multi threaded programs in C,C++.
View 3 Replies
View Related
Dec 14, 2010
In posix multi threading, how to send thread1 local data to thread2...?
View 3 Replies
View Related
May 20, 2009
There is a transient bug in my code which I just can't catch.
The basic idea is this. I have a multithreaded server and two thread pools, the IO pool and Worker pool. The main server thread listens to incoming connections. When it gets one, it dispatches a thread from the IO pool to read the socket. An IO thread reads the socket. If there is data, it invokes a thread from the Worker pool. This thread then finishes off the processing including closing the socket. The code follows.
Before I show the code, let me tell you what's happening when I am testing it. I have a client program which has about 30 threads, each opening a separate socket connection with the server. Each sends a request which the server responds to. Sometimes I have all the threads finish in a zip. Sometimes both the client and the server hangs. And yet at other times, the client gets a connection refused message.
Now the code. I have omitted some of the nitty-gritties, including possibly variable declarations. I'll post them if it's required.
View 1 Replies
View Related
Feb 25, 2011
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?
View 3 Replies
View Related
Feb 4, 2011
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.
View 3 Replies
View Related
Nov 29, 2010
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.
char info [256];
bzero(info, 256);
//memset(&info,0,sizeof(info));
read(socket, info, 255);
write(socket, HTTP, 255);
FILE *fl= fopen(info,"rb");
fseek(fl, 0, SEEK_END);
long len = ftell(fl);
printf("largo: %ld", len);
unsigned char *ret = (char*) malloc(len);
fseek(fl, 0, SEEK_SET);
fread(ret, 1, len, fl);
However, it's supposed to be shown in Mozilla Firefox (as the client). But it is not doing it, so.. It's just not getting the complete file.
View 1 Replies
View Related
Apr 7, 2011
Using Ubuntu server 10.04.2 64-bit all up to date.
I am running multi-threaded processes. These use OpenMP in my own code and the multi-threaded ACML maths library. When run in the foreground, everything is fine i.e. if I have set
export OMP_NUM_THREADS=8
then when I start all 8 cores are in use and things whizz along. However, when running overnight and logged out using e.g. 'at now + 1 minute' then the command, I am only getting about 130% CPU and it slows down accordingly. I have tried renice'ing and calling from within a bash script in case sh is doing something odd but nothing seems to solve it. I am sure that in the recent past this wasn't the case.
The libraries being used are shared versions in case that might have any bearing.
View 1 Replies
View Related
Apr 29, 2011
I am implementing a proxy server in c++. It is multithreaded(posix).Used CPU : Xeon(8core) Thread number : 8 One main thread, and other 7 thread created by the main thread. The main thread always listen to ports. When the main thread gets a client data it push the request in a queue[there are one queue(total 7) for each thread] based on ip and then give a signal to the appropriate thread. Then that thread gets the request from it's queue and process data and then forward the data to a appropriate destination.
There is another important thing, I assign each thread excluding the main thread to individual core by using affinity.The main thread listens to 5 ports. Test environment: We run the server. The client sends audio data at a particular rate.
1. The main thread CPU usage gets overloaded (above 80%) after a certain load from client.
2. Other cores remain about 0-10%.
The thing is that we want to distribute the load among all the cores equally by multithreading. But how can we do this ? Can the listening task of ports also be distributed ? I need an efficient algorithm for load balancing among threads. The data sent and receive rate of server is about 8.5MB/s. How can we improve this ? we are using gigabit LAN card. When the server only receive data from client it can receive data above 80MB/s. But when it both receives and sends data simultaneously it only manage upto 8.5MB/s.
View 1 Replies
View Related
Jun 16, 2011
I wonder if it is possible to avoid JNI in order to port a c/c++ STL application to android ?Do I have an alternative for calling C/C++ (STL) code ?
View 2 Replies
View Related
Jul 1, 2010
I need a loop that pulls out the user name into a variable and then pulls out the LastUpdate field into another variable so I can then perform a comparison against the last update field. Requirements are AIX tools including AWK, SED and Perl I am writing a script to check AIX users password expiration dates and if they are within the alerting period (ie. 7 days etc) it will email the user. I will release the full script into the public domain once completed. The text file I want to parse is formatted like:
Code:
colettel:
password = XSON0m4SdIQDw
lastupdate = 1260829398
andrewwa:
[code].....
View 4 Replies
View Related
Sep 22, 2010
I wrote a program that multiplies 2 matrices using multi-threads and another one using multiple processes and shared memory. Both in C.I need to find the total memory usage of these programs. I know of the top command, but when my matrices are relatively small they don't even show up on top because they complete so fast, how can I find the memory usage for these instances?Also, how can I find the total turnaround time of my programs
View 1 Replies
View Related
Sep 21, 2010
So I have apache running on my local computer. When I open up local development sites in tabs in my browser, apache threads are started. That's as it should be. However, when I close the tabs, close the browsers, and then run system monitor/system task manager, I get a long list of apache threads that are sleeping, waiting around for god knows what. How do I get these apache threads to stop hanging around?
View 1 Replies
View Related
Jun 16, 2014
app deployment on Linux/debian and I'm using Debreate to create .deb packages which works fine. I install the software itself to /usr/bin but want to install the program's database to /home/username/myapp/ The problem is it that I don't know how to add the env variable 'username' to the target path. What is the exact syntax for this installation path?
View 3 Replies
View Related
Jun 11, 2009
I am currently taking a Java class and I am not understanding it very well. I have compiled the following program, but it will not give me any data back to where I input the employee name, hours, rate. Can you look it over and tell what I am missing? I have been working on this for about 7 hours now and I have been reading and researching and just can not seem to know what is missing.
public class Employee
{
public static void main( String args[] )
[code]...
View 4 Replies
View Related
May 14, 2010
How system call internals could be known ? I mean for example if i take the example of write system call of linux kernel, where i can find out the code of write() system call in the kernel source tree ? The problem is write() system call directly write on console.If we want to write the data on some web page then write() system call will not do that ? How to redirect out data from console to application like html/web page?
View 6 Replies
View Related
May 3, 2010
I have written an application which has more than 6 threads.Two threads share a common linked list. Out of two threads one thread reads the linked list node and other thread writes to linked list node.I am using pthread_mutex_lock() API to achieve synchronisation between having access to common linked list. The problem is the first thread which reads the linked list accesses the mutex faster making other thread to starve.
I want both the thread to have an access to mutex. It should not happen that always first thread locks, releases and relocks it. The first thread almost require to access the link list every 5 msec which is causing second thread not to gain the mutex.How should I fix this? For information, I am running this application on PXA270 ARM platform.
View 4 Replies
View Related
Jan 24, 2011
What ubuntu server setup will work the best on a non web mostly data based via sockets (mysql php phpadmin) will be the easiest to use and what sockets to use? Lamp?
View 1 Replies
View Related
Jun 25, 2010
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)?
View 2 Replies
View Related
Mar 29, 2010
I have (adsl router "rebotic") and we are 3 nodes sharing Internet the question is: want make network (exchange files) between me (ubuntu os) and one of my internet members ,and I don't know how can I set up network between us in ubuntu.
View 1 Replies
View Related
Jun 26, 2011
I am looking for an equivalent software of Microsoft Exchange server. Right now we are using MS Exchange Server with 40 users. Can I transfer this setup to any equivalent RHEL programs? Is There A Linux Equivalent To Microsoft Exchange?
View 4 Replies
View Related
Oct 28, 2010
I am writing a code in Python where a socket client changes data with the server. That works nice if the connection is up. However it is also supposed to work offline. So I need to be able to detect if the connection is up before sending data, but I was not able to do so. A summary of the code is like that:
Code:
try:
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect( (self.host, self.port) )
connected = True
except:
connected = False
if connected:
data = "some data byte"
try:
socket.send(data)
except:
connected=False
socket.close()
If I unplug the cable after the connection is ready then the socket sends data and does not detect the connection failure. What is amazing is that the client detects the connection failure just after the cable has been plugged again. Of course there is a loop in the code above and always that connected==False a new connection is made. How could the program detect the connection failure before sending data and then lead the code to an exception?
View 3 Replies
View Related
Sep 28, 2010
i want a process that can operate as both a TCP echo server and a UDP echo server. The process can provide service to many clients at the same time, but involves a single process that does not start up any other threads.
View 3 Replies
View Related
Dec 1, 2010
I have two threads & i want to run it continuously ,with while(1) it is possible . Is there any other way to run the threads continuously
View 12 Replies
View Related
Nov 18, 2010
Is there any way to implement a simple ping script in C (unix)? I'm programming simple OpenWRT scripts.
I have found some examples of ping in C:
[URL]
However, nothing happens, nothing is sent.
When I look at the code, in the portion where the socket is created, I can see that the socket is not binding to any interface:
Code:
if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1)
{
perror("socket");
exit(EXIT_FAILURE);
}
setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &optval, sizeof(int));
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?
View 1 Replies
View Related
Nov 25, 2010
In all the examples I have found the server accepts the client's conection, proccess the data received and close the socket. In an very schematic way it would be something like:
Code:
client_thread{
select to see if there is data to read from socket fd
if there is something to read{
[code]....
Should I use mutexs or semaphores to block the socket fd before read and write or it is not necesary?
View 4 Replies
View Related
Dec 29, 2010
How to list all the threads spawned by a process?
View 4 Replies
View Related
Mar 26, 2011
I wrote a C program using Pthreads to compute the product of 2 matrices. Each element in the product matrix is computed in a separate thread. Eg: Thread (i,j) computes the element C[i][j] of the matrix C, where C=A*B. A is m*n, B is n*p, C is m*p. m,n,p are given as command-line arguments. A and B are initialized to random values from 1 to 10, while all elements of C are initialized to -1.But some threads do not get their arguments (i,j) correctly. So some elements C[i][j] still remain as -1, even after the program is over. My OS is Ubuntu 10.10 (Maverick Meerkat) 32-bit.I ran the program on another computer and it worked correctly. Is it due to a problem in the Pthreads library in my OS? Please help me. I have attached the source code.
View 3 Replies
View Related