当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

C语言网络编程问题

更新:02-12 整理:39baobao.com
字体:

[c语言中 beep是个什么函数]是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面: TC 试: #include<dos.h> #include<conio.h> #include<stdlib.h> /* this founction plays sound until hit any key */ v...+阅读

//UDP服务代码 // Module Name: Receiver.c // // Description: // This sample receives UDP datagrams by binding to the specified // interface and port number and then blocking on a recvfrom() // call // // Compile: // cl -o Receiver Receiver.c ws2_32.lib // // Command line options: // sender [-p:int] [-i:IP][-n:x] [-b:x] // -p:int Local port // -i:IP Local IP address to listen on // -n:x Number of times to send message // -b:x Size of buffer to send // #include#include#include#define DEFAULT_PORT 5150 #define DEFAULT_COUNT 25 #define DEFAULT_BUFFER_LENGTH 4096 int iPort = DEFAULT_PORT; // Port to receive on DWORD dwCount = DEFAULT_COUNT, // Number of messages to read dwLength = DEFAULT_BUFFER_LENGTH; // Length of receiving buffer BOOL bInterface = FALSE; // Use an interface other than // default char szInterface[32]; // Interface to read datagrams from // // Function: usage: // // Description: // Print usage information and exit // void usage() { printf("usage: sender [-p:int] [-i:IP][-n:x] [-b:x]\n\n"); printf(" -p:int Local port\n"); printf(" -i:IP Local IP address to listen on\n"); printf(" -n:x Number of times to send message\n"); printf(" -b:x Size of buffer to send\n\n"); ExitProcess(1); } // // Function: ValidateArgs // // Description: // Parse the command line arguments, and set some global flags to // indicate what actions to perform // void ValidateArgs(int argc, char **argv) { int i; for(i = 1; i3) iPort = atoi(&argv[i][3]); break; case 'n': // Number of times to receive message if (strlen(argv[i]) >3) dwCount = atol(&argv[i][3]); break; case 'b': // Buffer size if (strlen(argv[i]) >3) dwLength = atol(&argv[i][3]); break; case 'i': // Interface to receive datagrams on if (strlen(argv[i]) >3) { bInterface = TRUE; strcpy(szInterface, &argv[i][3]); } break; default: usage(); break; } } } } // // Function: main // // Description: // Main thread of execution. Initialize Winsock, parse the command // line arguments, create a socket, bind it to a local interface // and port, and then read datagrams. // int main(int argc, char **argv) { WSADATA wsd; SOCKET s; char *recvbuf = NULL; int ret, i; DWORD dwSenderSize; SOCKADDR_IN sender, local; // Parse arguments and load Winsock // ValidateArgs(argc, argv); if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { printf("WSAStartup failed!\n"); return 1; } // Create the socket and bind it to a local interface and port // s = socket(AF_INET, SOCK_DGRAM, 0); if (s == INVALID_SOCKET) { printf("socket() failed; %d\n", WSAGetLastError()); return 1; } local.sin_family = AF_INET; local.sin_port = htons((short)iPort); if (bInterface) local.sin_addr.s_addr = inet_addr(szInterface); else local.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(s, (SOCKADDR *)&local, sizeof(local)) == SOCKET_ERROR) { printf("bind() failed: %d\n", WSAGetLastError()); return 1; } // Allocate the receive buffer // recvbuf = GlobalAlloc(GMEM_FIXED, dwLength); if (!recvbuf) { printf("GlobalAlloc() failed: %d\n", GetLastError()); return 1; } // Read the datagrams // for(i = 0; i

本文地址:https://www.39baobao.com/show/29_40146.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

谁会用c语言编一个音乐播放器 。。#include #include #include #include #include void main() { void set(int *set1,int *set2,char *f,char *n,int *t,int rate,int num); void music(int *set1,int *set2...

求一个单片机c语言音乐程序#include#define uchar unsigned char #define uint unsigned int sbit BEEP=P3^2; // 生日快乐歌的音符频率表,不同频率由不同的延时来决定 uchar code SONG_TONE[]={212,212...

跪求一个单片机生日快乐歌C语言程序#include <reg52.h> #define uint unsigned int #define uchar unsigned char sbit BEEP=P1^2;//接喇叭或蜂鸣器的接口 uint h,i; uint hz; uchar jiep; bit flag; uint code...

求c语言编写蜂咛器唱歌 7个音阶的从低到高的十六进制代码#include<windows.h> #define N 14 enum FREQUENCY{ Fc=131, Fd=147, Fe=165, Ff=175, Fg=196, Fa=220, Fb=247, Fc1=262, Fd1=294, Fe1=330, Ff1=349, Fg1=392, Fa1=440, F...

C语言问题之进制回文数我就只写回文数判定的函数,你自己调用就行了,其他的感觉你会 #include <stdlib.h> #include <string.h> int fun(int n) {int i,j; char s[30]; itoa(n,s,10); for(i=0,j=strl...

C语言程序题函数判断回文数# include //添加头文件 int main(void)//主函数 { int val; int m; int sum = 0;//定义三个整型变量,分别是val m sum,其中sum赋初值位0 printf("请输入您需要判断的数字:"); scanf(...

C语言:查找回文素数找出大于整数m且最靠近m的回文素数函数#include <stdio.h> #include <math.h> int IsPalin(int n){ char a[20]={},i=0,j; while(n > 0){ a[i] = n % 10; n = n / 10; i++; } i--; for(j=0;j<(i+1)/2;j++) if(a[j...

视频语言怎样转换首先你要找到这个电影的字幕文件 然后使用Subtitle Workshop、SUBmax、StrEdit等编辑软件编辑字幕 比如在电影播放到20分30秒的时候,男主角说“hello” 你就在字幕编辑中找到...

英雄联盟各种语言什么意思ID:你的游戏角色名字 楼主/房主/LZ:创建游戏房间的人 FB:1血,也是DOTA类游戏的魅力之一,FB的全称是firstblood,指第一个杀死的英雄,不光有击杀英雄的奖励,还会额外的奖励的100元(杀...