Say it is connecting, and I think it is, but only for a split second because my server doesn't show the connection, but unless the server is on, the program returns the error..anywasy:
how do I get the information being sent to me, and output it to the screen? This is what im doing, it returns "T":
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>
void main ( void )
{
WSADATA WsaDat;
if (WSAStartup(MAKEWORD(1, 1), &WsaDat) != 0)
{
printf("WSA Initialization failed.");
}
int Socket;
Socket = socket(AF_INET, SOCK_STREAM, 0);
if (Socket == INVALID_SOCKET)
{
printf("Socket creation failed.");
}
struct sockaddr_in SockAddr;
if (Socket < 0) {
struct sockaddr_in SockAddr;
perror("socket");
}
SockAddr.sin_port = htons(50);
SockAddr.sin_family = AF_INET;
SockAddr.sin_addr.s_addr = inet_addr( "127.0.0.1" );
if( connect(Socket, (struct sockaddr *)(&SockAddr), sizeof(SockAddr)) < 0 ) {
printf( "\nCould not connect to remote server.\n" );
}
else {
connect(Socket, (struct sockaddr *)(&SockAddr), sizeof(SockAddr));
char *re[30];
recv(Socket, *re, 30, 0);
printf("%c", &*re);
}
}