Sponsored Content
Full Discussion: UDP sockets
Special Forums IP Networking UDP sockets Post 102152 by strider on Thursday 16th of March 2006 03:47:25 AM
Old 03-16-2006
UDP sockets

hi...
i have made this client server prog with UDP sockets but im not getting the output. the client sends the message but the server just keeps on waiting. Im running the prog an a solaris 10 box...

server:
Code:
main()
{
   	int   sd;
	struct   sockaddr_in server;
	char buf[512];
	int rc,len;

	server.sin_family = AF_INET;
   	server.sin_addr.s_addr = htonl(INADDR_ANY);
   	server.sin_port = htons(1234);

   	sd = socket (AF_INET,SOCK_DGRAM,0);

  	if(bind ( sd, &server, sizeof(server))==-1)
		printf("error\n");
	else
		printf("ok\n");

 	len=sizeof(server);
	printf("check\n");
   
    	printf("check1\n");
      	rc = recvfrom (sd, &buf[0], 2, 0,&server, &len);
      	printf("check2\n");
      	buf[rc]= '\0';
      	printf("Received: %s\n", buf);
}

client
Code:
main()
{

        int	sd,a;
	struct	sockaddr_in server;

	sd = socket (AF_INET,SOCK_DGRAM,0);

	server.sin_family = AF_INET;
	server.sin_addr.s_addr=htonl("127.0.0.1");
	server.sin_port = htons(1234);

	a=sendto(sd, "HI",2, 0,&server, sizeof(server));
        printf("sent=%d\n",a);
        exit(0);

}

 

10 More Discussions You Might Find Interesting

1. IP Networking

udp help?

hi all, newbie here, i'm working on mac os x and i'm trying to stream some info using udp from the terminal to another app that listens for osc messages on the same machine. but the man page on udp is pretty cryptic. my question is whether anyone has a recommendation for a good tutorial covering... (0 Replies)
Discussion started by: ohhmyhead
0 Replies

2. IP Networking

concurrent udp server

Just like concurrent tcp server, anyone know how to design the concurrent udp server with the thread? it's best to give some basic examples,thanks (0 Replies)
Discussion started by: Frank2004
0 Replies

3. UNIX for Advanced & Expert Users

SUN OS - UDP parms

Hi there, Does anyone know of a place that will give details for each of the following UDP parms? I've found documentation on there size limits but not what they will do or affect if changed. udp_xmit_hiwat udp_xmit_lowat udp_recv_hiwat udp_max_buf ... (1 Reply)
Discussion started by: nhatch
1 Replies

4. UNIX for Advanced & Expert Users

udp sockets of dns requests not showing anywhere...

Dear guys, I am facing the most weird problem I have ever encountered! Ok here is the situation: From my dns query.log file - it is generated using usual bind9 logging: logging { channel query.log { file "/var/log/bind9/query.log" versions 10 size 2m; severity debug 2;... (0 Replies)
Discussion started by: angeloio
0 Replies

5. UNIX for Advanced & Expert Users

UDP errors

Hi, I can see "udpInOverflows" errors when I execute 'netstat -s' on my Solaris box. The number of errors are small - about 40. e.g. $ netstat -s|grep udp UDP udpInDatagrams =1249190732 udpInErrors = 0 udpOutDatagrams =31663030 udpOutErrors = 0... (1 Reply)
Discussion started by: chaandana
1 Replies

6. Programming

Print server via UDP

Hello, I would like to ask you for a help. I need to program in C print server which is based on connectionless protocol UDP. The problem is that I am not experienced in programming network applications, I can help myself with some other answered questions on this forum about network apps in C,... (1 Reply)
Discussion started by: samciz
1 Replies

7. Windows & DOS: Issues & Discussions

UDP/ tunnel

Hi, I know tcp port tunneling can be done using ssh/putty. how about udp? I have a scenario where a license server handsout licenses to machines in that network ONLY. I have a windows machine in a different subnet and even though the client software can see license server, while using the... (6 Replies)
Discussion started by: upengan78
6 Replies

8. UNIX for Dummies Questions & Answers

UDP

What's the command/options for UDP SOCK (Socket)? (5 Replies)
Discussion started by: Peevish
5 Replies

9. Infrastructure Monitoring

Tunneling UDP via SSH

Performing UDP tunneling through an SSH connection Found this while looking for a way to temporarily forward SNMP requests across otherwise disconnected networks. Might be useful for someone else, too. (1 Reply)
Discussion started by: pludi
1 Replies

10. Infrastructure Monitoring

UDP Port 161

hi guys My linux server have SNMP configure port by default is 161 (UDP) now my monitor team - who are using Nagios - say the server are not being monitor so check netstat -lnu and I see all is OK and snmp service is running fine what else should I check about this port 161? to see if it is... (0 Replies)
Discussion started by: karlochacon
0 Replies
XIQUERYVERSION(3)														 XIQUERYVERSION(3)

NAME
XIQueryVersion - announce and query the support XI2 version. SYNOPSIS
#include <X11/extensions/XInput2.h> Status XIQueryVersion( Display *display, int *major_version_inout, int *minor_version_inout); display Specifies the connection to the X server. major_version_inout Specifies the client's supported XI2 version, and returns the server's supported version. minor_version_inout Specifies the client's supported XI2 version, and returns the server's supported version. DESCRIPTION
XIQueryVersion announces the client's supported XI2 version to the server and returns server's supported X Input version. Clients are required to use XIQueryVersion instead of XGetExtensionVersion if they use XI2 calls. The server may treat a client differently depending on the supported version announced by the client. The major_version_inout must be 2 or greater, otherwise a BadValue error occurs. If the server does not support XI2, XIQueryVersion returns BadRequest to the client. Otherwise, XIQueryVersion returns Success. In both cases major_version_inout and minor_version_inout are set to the server's supported version. Consecutive calls to XIQueryVersion by the same client always return the first returned major.minor version. If the client requests a version lower than the first returned major.minor version in a subsequent call, a BadValue error occurs. XIQueryVersion can generate a BadValue error. EXAMPLES
int rc; int major = 2; int minor = 0; rc = XIQueryVersion(dpy, &major, &minor); if (rc == Success) printf("XI2 supported. (%d.%d) ", major, minor); else if (rc == BadRequest) printf("No XI2 support. (%d.%d only) ", major, minor); else printf("Internal error "); DIAGNOSTICS
BadValue A value is outside of the permitted range. 05/15/2013 XIQUERYVERSION(3)
All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy