Networking :: Sending / Receiving Data Simultaneously Using BSD Sockets
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
ADVERTISEMENT
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
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
Oct 27, 2010
I have a desklet that, occasionally after toying with network stuff, will tell me that large amounts of data are being sent/received. What's a good way to determine what processes are occupying these resources?!
View 14 Replies
View Related
Aug 19, 2010
I wrote an application that receives packets on one interface and sends them to another interface after it added a vlan header. Both the sending and the receiving is done using raw sockets. Everything seems to work fine until I get TCP packets that are of size 1514 (MTU). Once I add a vlan header to the packet, its size becomes 1518 and when I try to send it I get the returned value -1 and errno=90 (message too long). I tried to change the MTU of the NIC to a value that is bigger than 1500 but that fails. If I create a bridge using brctl and vconfig between the NICs I can see that my NIC does sends packets of size 1518. What do I need to in order to make my NIC to send packets of size 1518?
View 5 Replies
View Related
Mar 8, 2010
We have connected two systems with ethernet cables and have configured the two systems with ipv6 addresses. The IP of one system is 2001:0db8:0:f101::1 (let's say X::1) (This system runs OS Fedora 10) and the other is 2001:0db8:0:f101::2. (Let's say X::2) (This system runs OpenSuSE 10.3) We are able to ping from both systems to the other. We are able to ssh into the one with IP X::2 from the one with IP X::1, but not vice versa.
We have disabled iptables on both systems by using the following commands:
/etc/init.d/iptables save
/etc/init.d/iptables stop
on the fedora 10 system and
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -P INPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT
on the openSuse system.
The error we get in trying to ssh from the openSuse system to the fedora system is:
ssh: connect to host 2001:0db8:0:f101::1 port 22: Connection refused
We're trying to write server and client code to send data from one system to the other using SOCK_DGRAM. The code works fine when we run both the client and server on the same system. However, we are not able to send data from one system to another when we use the IPv6 addresses to run the client and server programs.
The error we get is:
sendto(): Operation not permitted
The codes we are using for the server and client programs can be found here in beej's guide here : [URL]. We've only substituted the appropriate addresses in the right places... We've disabled the iptables...
View 1 Replies
View Related
May 19, 2010
I have a server which is used by number of client Apps. Now when a client initiates a sendto request to a server it has to respond(after recvfrom) by sending a message using sendto back to client and this should be done back and forth.
What I dont understand is, does the client have to open a new port to receive packets from client? If yes, then how will server know to what port of the client(assuming server ports are well-known to clients)?
I had given up on sending messages back and forth using UDP and switched to TCP. I could send a read and write message back and forth. But the trouble comes when I have more than one client wanting to talk to server using SOCK_STREAM. The first one gets through but the second client seems to get blocked forever(but I got no error upon socket creation or upon connect with the server on the same port as the previous client)..
View 4 Replies
View Related
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.
View 3 Replies
View Related
May 18, 2010
I have recently set up nagios on a ubuntu server (9.10), and set it up to monitor all the servers, switches etc, following the quickstart guide provided on the nagios website.My problem is this:I have setup the nagios-plugins, and tried to set it up to monitor the network switches via SNMP but receive the following within the nagios web interface:SNMP problem - No data received from host I tried it from the command line, and got the exact same error.Is there some further configuration I need to do to be able to get this data?I've used up all my google-fu, and read over everyone else's problems on every forum I could find, but to no avail.
View 6 Replies
View Related
Nov 8, 2010
Yesterday i run a postfix everything works fine and today it hangs up. if i dial "telnet localhost 25" i get (before day i get 220 answer and ordinary hello):
Code:
Trying 62.197.207.43...
Connected to trons.sk.
Escape character is '^]'.
and nothing go far.
[Code]....
View 2 Replies
View Related
Nov 23, 2009
i have a problem regarding our email server. all the users can send email but they cant received mail. .when hitting send receive on outlook there were no error found. .i have already reboot the server and restarted the sendmail services but still same problem.
View 1 Replies
View Related
Jan 22, 2011
I have followed the guide for "The Perfect Server - Debian Lenny (Debian 5.0) With BIND & Dovecot [ISPConfig 3]" and all is well, except.
I can send mail (to GMail) from commandline. I can send mail (to GMail) from any of the domains configured in ISPConfig3 through SquirrelMail (how ever terrible that looks, but functions) or IMAP/POP.
but....
I can't receive mail (from GMail) on any of the domains configured in ISPConfig3 in SquirrelMail or IMAP/POP.
I have my domains configured with proper MX records (just like I have them configured at work). I have all ports (80, 143, 110, 25, 22, etc) forwarded on my router that are needed.
I can Telnet to localhost and all checks are fine. I can send and receive from and to local domains on the same server, which makes sense. but
I can't Telnet from any external server to my server behind NAT.
Conclusion:
I figured it MUST be a network/port-forwarding problem as the external Telnet requests fails to my machine on port 25.
Tested my router if it would let met communicate through port 25 and it would.
So it must be my ISP, as I read in different posts.
Question:
Maybe I'm a n00b, but in all other posts the problems were with receiving AND sending.
My ISP responded that port 25 is blocked because of spam issues.
But I can mail (and even spam if I would like to) to external domains while I didn't do anything weird to make that happen.
The only thing I wish for is to receive mails and if you'd ask me, port 25 would be solely for outgoing mails, not for incoming mail deliveries throught MX?
An ISP surely wouldn't disable their customers in having a mail-server for incoming mails, as long as they would send out through their own smtp server to make sure they wouldn't spam the world?
View 1 Replies
View Related
Jun 17, 2010
i am using centos 5.4, running squid for proxy, i want to block email sending and receiving of proxy users to secure my data. how is it possible that the proxy user can only brows websites but he can not receive or open and send or save as draft to mail box.
View 1 Replies
View Related
Jan 21, 2010
One of our postfix servers is for sending/receiving internal emails only. When a user entered a wrong recipient address, it will take almost an hour for the user to get the "Recipient address rejected" email. What can be done to let the user get the "Recipient address rejected" email quickier.
View 7 Replies
View Related
Feb 12, 2011
I'm using Huawei E1550 3G modem. Any tool so that I can send and receive sms, even USSD also...
View 1 Replies
View Related
Jun 22, 2010
Please tell me how i can block sending or receiving .exe files as a attachment in sendmail server
View 1 Replies
View Related
Apr 19, 2011
I am looking for free and well known fax command line tools for receiving and sending faxes I wan it to save receive faxes in pdf format with file name included with caller phone number and date of receive:
Quote:
for example:
5566545544-2011-5-11.pdf
and any other format that I want.
View 11 Replies
View Related
Jun 29, 2010
shed some light on what I am doing. I am wondering if I just havehings back to front.Server (MESH):Fedora 13Firewall ports open tcp 22(ssh), tcp 873(rsync)sshd service started
View 5 Replies
View Related
Jan 25, 2010
I want to send raw data to a usart port of my board connected to linux box. i know the command
echo "abcxyz" > /dev/<usb_dev_file_name>
would write the raw bits for characters abcxyz to the usb device but the problem is how do i know which device file to write to?there are so many in my /dev.
View 1 Replies
View Related
Apr 23, 2009
I'm working on testing some software, and I have a question. We have several files of binary data that we need to push through our application to test. It communicates via simple TCP sockets. Is there a way I can send this data to the socket from the command line? I tried doing something like this, but telnet never picked up the data.
View 5 Replies
View Related
Apr 6, 2011
I checked task manager the other day and I discovered that on the network history monitor some bits and bites were transfered in a repeating pattern (like a beacon). The transfer rate (when active) is about 149b/s receiving. And about 70b/s sending. What is this?
No Internet-related program was running from my part...In an attempt to pinpoint what was causing this, I occidentally removed the tools located left and right on the time and date. I've rebooted since but still no tools. The 0/I button is also gone.
View 5 Replies
View Related
Apr 15, 2010
I am trying to redirect connection to port 8980 to execute a telnet command to a local machine
by issuing the following command :
In Server 1 :
socat TCP-LISTEN:8980,fork EXEC:/myscript,reuseaddr
My script contains
#!/bin/bash
telnet 192.168.20.12 //local Server 2
I am sending Binary data from the client to Server 2 via Server 1. So it happens that I have some characters in Hex translated to special characters in ASCII like open brackets or Commas etc.. and that closed the socket between the two machines.
View 2 Replies
View Related
Mar 30, 2010
I want to know that by default do we need to configure SMTP and POP3/IMAP sever for sending and receiving mails in Linux server and client machines or we can directly send and receive mails without configuring these mail servers?
View 2 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
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
Nov 6, 2010
I am trying to port some MS Visual Studio C++ code to Linux/wxWidgets. The code is socket-based and very similar between Windows and Linux. In Linux the socket, bind, and setsocketopt all return with no error. See:
Code:
BOOL CAV15Input::SetupSocket(BOOL Out)
{ if(pU->PrDebug) {
sprintf(_send,"CAV15Input::SetupSocket for port %d",pSonar->dPort);
pU->OutMsg(_send,1,0); } pSonar->UDP_Sock=0; pSonar->UDPError=0;
pSonar->UDP_Sock=socket(AF_INET,SOCK_DGRAM,0);
if(pSonar->UDP_Sock<0 ) {
pU->OutMsg("socket failed on SetupSocket",11,0);
pSonar->UDP_Sock=0;
pSonar->UDPError|=4;
return FALSE; }
// the AF_INET address family, which contains IP addresses,
local.sin_family=AF_INET;
local.sin_addr.s_addr=inet_addr(pSonar->IP_Add_PC);
local.sin_port=htons(pSonar->dPort);
// from Dave Goffe:
//> int t = 1;
//>
//>setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&t,sizeof(t));
int t=1; if(setsockopt(pSonar->UDP_Sock,
SOL_SOCKET, SO_REUSEADDR,
(char *)&t,sizeof(t)) <0) {
CloseSock();
pU->OutMsg("set SO_REUSEADDR failed in SetupSocket",11,0);
pSonar->UDPError|=4;
return FALSE; }
if(bind(pSonar->UDP_Sock,(sockaddr *)&local,sizeof(local)))
{ CloseSock();
pU->OutMsg("bind failed in SetupSocket",11,0);
pSonar->UDPError|=8; return FALSE; }
if(pU->PrDebug) {
sprintf(_send,"socket setup & bind OK for port %d",pSonar->dPort);
pU->OutMsg(_send,1,0); }
// Join multicast group
if(pSonar->datatype) // for element data
mreq.imr_multiaddr.s_addr=inet_addr(pSonar->IP_Add_ELD);
else // for beam data
mreq.imr_multiaddr.s_addr=inet_addr(pSonar->IP_Add_HRB);
mreq.imr_interface.s_addr=inet_addr(pSonar->IP_Add_PC);
if(setsockopt(pSonar->UDP_Sock,
IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *)&mreq,sizeof(mreq)) <0) {
CloseSock();
pU->OutMsg("join multicast failed in SetupSocket",11,0);
pSonar->UDPError|=16;
return FALSE;
} if(pU->PrDebug) {
if(pSonar->datatype) // for element data
sprintf(_send,"join multicast OK on %s",pSonar->IP_Add_ELD);
else // for beam data
sprintf(_send,"join multicast OK on %s",pSonar->IP_Add_HRB);
pU->OutMsg(_send,1,0); }
jMCast=1; return TRUE; }
But then when I try
recv(pSonar->UDP_Sock,&pUDP->u_dg_cM.cM[8],reedlen,0);
it blocks as if there is no data. (In Windows this works fine.) Is there something else in Linux and/or wxWidgets that I'm missing that could prevent UDP datagrams from being received? Is there some way in Linux to monitor incoming UDP traffic?
View 2 Replies
View Related
Jun 2, 2010
I have setup Nagios, Nagios Plugins, and nrpe. I have the nrpe running through xinetd.When I run /usr/local/nagios/libexec/check_nrpe -H <my_ipaddress> and I get the error
CHECK_NRPE: Error receiving data from daemon
View 14 Replies
View Related
Jan 21, 2010
We know that, in a network, data transfer time is dependent on capacity of the receiving node. I have two Linux systems A (sender) and B (receiver) connected. I want to simulate congetion in a network, that means I want to increse the time taken to transfer some data. I believe, I can do this if I can reduce the capacity of the receiver node B. That perhaps possible by decreasing the receiving buffer size of B. How can I change the receiving buffer size of this linux system B?
View 1 Replies
View Related
Jan 28, 2011
currently I've got a big problem on programming with sockets. I use the winsock2 API and want to receive data from a multicast adress running on a UNIX-PC. The connection works fine and I really receive data from this group, but as it seems not the right packages. The received data is saved in a char[]. E.g. at received_msg[12] is a float value. This one I would like to read out, convert and use it in later progress the next value is y at received_msg[16]. The same Code works on a Unix PC with unix sockets but converted to winsock I've got the described problem and I have to make this code work under windows.
Here a piece of the code (received_msg[12]='3f'):
Buffer is a struct containing the two float values x and y. If I convert the char as this under windows the value of x is a huge number. The correct value is around 192, so receveid_message[12] should be 1.92. Could it be that the Unix-PC is sending data in an other way than the winsock receive it?
View 2 Replies
View Related