Connected!..... or not?

So I psuedo-wrote my own C server, and I am having it connect to an AC3 binary socket. Now i start up the server, and it says that it opened, and bound correctly. Then I start up the client and the server says that it connected, AC3 also connects and it gets the policy file and traces it. but when I try to send anything all I get is whitespace on the other end.

So here is the C server: (this was my first one ever, so there is a better than excelent chance that this is horribly wrong)

 
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>

int main () 
{
    int sockfd, newsockfd = -2, clilen;
	socklen_t client_len;
	int portno = 1500;
	char buffer[256], sendLine[46] = "<allow-access-from domain=\"*\" to-ports=\"*\" />";
	struct sockaddr_in serv_addr, cli_addr;
	int n = 0;
	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if (sockfd < 0) 
	{
		printf("ERROR opening socket
");
	}
	else {
		printf("opened
");
	}

	
	
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	serv_addr.sin_port = htons(portno);
	
	if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
	{
		printf("ERROR binding
");
		close(sockfd);
	}
	else {
		printf("bound
");
	}

	
	listen(sockfd, 5);
	clilen = sizeof(cli_addr);
	while(1)
	{
		newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &client_len);
		if (newsockfd < 0) 
		{
			printf("ERROR on accept
");
		}
		else 
		{
			send(newsockfd, sendLine, 46, 0);
			printf("accpeted
");
		}
		while (n != -1) 
		{
			bzero(buffer, 256);
			n = recv(newsockfd, buffer, 255, 0);
			if (n < 0)
				printf("ERROR reading from socket
");
			else
			{
				printf("Data: %c %c %c %c 
" , buffer[0], buffer[1], buffer[2], buffer[3]);
			}
		}
	
		
	}
	
	getchar();
    return 0;
}

and the AC3, again this is my first one and I know im missing all the I/O error event handlers and whatnot, but i didn’t think they were important for just trying to get it initially working.


package  
{
	
	import flash.display.MovieClip;
	import flash.net.XMLSocket;
	import flash.events.ProgressEvent; 
	import flash.events.Event;
	import flash.net.Socket;
	import flash.utils.ByteArray;
	
	
	public class HelloServer extends MovieClip 
	{
		var sendData:ByteArray = new ByteArray();
		//sendData.writeByte(15);
		var socket:Socket = new Socket("localHost", 1500);
		public function HelloServer() 
		{
			socket.connect("localHost", 1500);
			socket.addEventListener(Event.CONNECT, connect);
			socket.addEventListener(Event.CLOSE, closeHandler)
			socket.addEventListener(ProgressEvent.SOCKET_DATA, dataEvent);
			addEventListener(Event.ENTER_FRAME, always);
			trace(socket.connected);
		}
		public function always(e:Event): void
		{
			trace(socket.connected);
			if (socket.connected)
			{
				trace("Writing...")
				{
					socket.writeByte(15);
				}
			}
		}
		public function closeHandler(e:Event): void
		{
			trace("Closed");
		}
		public function connect(e:Event): void
		{
			trace("Connected");
		}
		public function dataEvent(e:ProgressEvent): void
		{
			
			var test = socket.readUTFBytes(46);
			trace(test);
		}
	}
	
}