📄 cabecera.c
字号:
/* LiMon-Server| Copyright (C) 2006 Marcelo Busico|| Author: Marcelo Busico marcelobusico@gmail.com|| This program is free software which I release under the GNU General Public| License. You may redistribute and/or modify this program under the terms| of that license as published by the Free Software Foundation; either| version 2 of the License, or (at your option) any later version.|| This program is distributed in the hope that it will be useful,| but WITHOUT ANY WARRANTY; without even the implied warranty of| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the| GNU General Public License for more details. Version 2 is in the| LICENSE.txt file in the top level directory of this distribution.| | To get a copy of the GNU General Puplic License, write to the Free Software| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*//* Implementacion de la libreria que envia y recibe la cabecera */#include "cabecera.h"#include "socket.h"#include <netinet/in.h> #include <string.h>/* Retorna la cabecera leida de la red por el descriptor del Socket */Cabecera recibirCabecera(int sockfd){ Cabecera cabecera; int lectura=0; char pass[64]; /* Lee el identificador */ Lee_Socket(sockfd, (char*)&lectura, sizeof(int)); cabecera.identificador=ntohl(lectura); /* Lee la password */ Lee_Socket(sockfd, pass, sizeof(pass)); strcpy(cabecera.password,pass); /* Retorna la cabecera */ return cabecera;}/* Envia la cabecera a la red por el descriptor del Socket */void enviarCabecera(int sockfd, Cabecera cab){ int id=0; char pass[64]; /* ID en formato de red */ id=htonl(cab.identificador); /* Envia el id de la cabecera por la red */ Escribe_Socket(sockfd, (char*) &id, sizeof(int)); /* Envia la password de la cabecera por la red */ Escribe_Socket(sockfd, cab.password, sizeof(pass));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -