Latest Episode
 

Go Back   Keith and The Girl Forums Keith and The Girl Forums Talk Shite

Talk Shite General discussion

Reply
 
Thread Tools Display Modes
Old 05-05-2009, 12:29 AM   #231 (permalink)
Senior Member
 
outlaw's Avatar
 
Join Date: Jan 2006
Location: ATL
Posts: 168
Quote:
Originally Posted by hayroob View Post
Tongues your balls and feeds you jello
Well, there's the app I'm looking for. Damn, why didn't you say so.
(Offline)   Reply With Quote
Old 05-05-2009, 12:36 AM   #232 (permalink)
Senior Member
 
yoav's Avatar
 
Join Date: Apr 2006
Posts: 1,050
Quote:
Originally Posted by hayroob View Post
Tongues your balls and feeds you jello

i think they're holding out on jello for the next next iphone. it's not that they don't have the tech, they just don't wanna set the bar too high. personally i'm with you though, without jello the ball tonging seems almost pointless.
(Offline)   Reply With Quote
Old 05-05-2009, 07:49 AM   #233 (permalink)
Senior Member
 
picard102's Avatar
 
Join Date: Aug 2006
Location: Toronto, Ontario
Posts: 3,065
Playing with the graphics again. Cleaning it up a bit and packaging things up.
Attached Images
File Type: jpg Graphic1..jpg (69.6 KB, 3 views)
File Type: jpg feedback-screen-air.jpg (56.1 KB, 0 views)
(Offline)   Reply With Quote
Old 05-05-2009, 02:32 PM   #234 (permalink)
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
Ok this is the PHP I am using to listen for incoming data.
Code:
<?php
$pushNotifications = new pushNotifications();

class pushNotifications {
	/*private $serviceHost = '127.0.0.1';*/
	private $serviceHost = '192.168.0.102';
	private $servicePort = '1233';
	
	private $serviceConnection;
	
	function __construct(){
		$this->listenForClients();
		$this->closeConnections();
	}
	
	function listenForClients(){
		$this->serviceConnection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
		socket_bind($this->serviceConnection, $this->serviceHost, $this->servicePort);
		socket_listen($this->serviceConnection, 10);
		
		while($clientSocket = socket_accept($this->serviceConnection)){
			$clientMessage = socket_read($clientSocket, 1024);       
			
			$filename = 'tokenLog';
			// Let's make sure the file exists and is writable first.
			if (is_writable($filename)) {
			    // In our example we're opening $filename in append mode.
			    // The file pointer is at the bottom of the file hence
			    // that's where $clientMessage will go when we fwrite() it.
			    if (!$handle = fopen($filename, 'a')) {
			         echo "Cannot open file ($filename)";
			         exit;
			    }
			    // Write $clientMessage to our opened file.
			    if (fwrite($handle, $clientMessage) === FALSE) {
			        echo "Cannot write to file ($filename)";
			        exit;
			    }
			    echo "Success, wrote ($clientMessage) to file ($filename)";
			    fclose($handle);
			} else {
			    echo "The file $filename is not writable";
			}
			
			socket_close($clientSocket);
		}
		
		
	}
	
	function closeConnections(){
		socket_close($this->serviceConnection);
	}
}
?>
I start that with php -f tokenServer.php
and it works fine.

I can do:
Code:
telnet 192.168.0.102 1233
I can also telnet to the external ip of my network because I've set up that computer in the dmz.

once I'm connected to telnet I can type in whatever and hit enter and it gets written to tokenLog. This works reliably.

So I've written some objective-c code to send some data to the server but I can't get it to bind. Here's where I'm stuck:
Code:
- (void)sendProviderDeviceToken {
	NSLog(@"sendProviderDeviceToken");
	int fd = -1;
	CFSocketRef socket;
	socket = CFSocketCreate(kCFAllocatorDefault, 
							PF_INET, 
							SOCK_STREAM,
							IPPROTO_TCP, 
							0, 
							NULL, 
							NULL);
	if ( socket == NULL) {
		NSLog(@"CfSocketCreate Failed");
	}else{
		if( socket ) {
			fd = CFSocketGetNative(socket);
			if (fd == -1) {
				
			NSLog(@"CfSocketGetnative Failed");
			} else {
				int yes = 1;
				setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes));
				
				struct sockaddr_in addr;
				memset(&addr, 0, sizeof(addr));
				addr.sin_len = sizeof(addr);
				addr.sin_family = AF_INET;
				addr.sin_port = htons(1233); //port
				inet_aton("68.43.107.247", &addr.sin_addr); //ip adress
				NSData *address = [NSData dataWithBytes:&addr length:sizeof(addr)];
				CFSocketError e = CFSocketSetAddress(socket, (CFDataRef)address);
				if(e != kCFSocketSuccess ) {
					NSLog(@"Could not bind to address");
				} else {
					char msg []= "helloworld";
					CFDataRef Data = CFDataCreate(NULL, (const UInt8*)msg, sizeof(msg));
					CFSocketSendData(socket,NULL, Data, 1000);
					NSLog(@"Data Sent");
				}
			}
		} else {
			NSLog(@"No server socket");
		}
	}
}
__________________
If you like the KATG app feel free to kick in some bucks (or don't)
KATGIPHONE Donation
(Offline)   Reply With Quote
Old 05-05-2009, 06:41 PM   #235 (permalink)
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
Ok tackled most of my problems with this:
Code:
- (void)sendProviderDeviceToken:(id)deviceTokenBytes {
	NSLog(@"sendProviderDeviceToken");
	
	CFWriteStreamRef myWriteStream = nil;
	
	CFReadStreamRef myReadStream = nil;
	
	CFStringRef url = CFSTR ("whywontyoudie.com");
	
	CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault,
										url,
										1233,
										&myReadStream,
										&myWriteStream);
		
	//CFDataRef Data = CFDataCreate(NULL, (const UInt8*)deviceTokenBytes, sizeof(deviceTokenBytes));
	
	const UInt8 *test = (UInt8*)&deviceTokenBytes;
	
	if (myWriteStream != Nil && CFWriteStreamOpen (myWriteStream)==true && CFReadStreamOpen (myReadStream)==true) {
		CFIndex result = CFWriteStreamWrite ( myWriteStream, (UInt8*)&deviceTokenBytes, sizeof(deviceTokenBytes));
	}
	
}
Which connects and sends data just fine. But insists on formating the deviceTokenBytes into UInt8 which scrambles it all up and is very annoying. Working on how to do a writestream without UInt8.
(Offline)   Reply With Quote
Old 05-05-2009, 07:06 PM   #236 (permalink)
Senior Member
 
The Gunner's Avatar
 
Join Date: Mar 2007
Location: Texas, Motherfucker.
Posts: 470
Any word on when version 1 will hit iTunes? The adhoc isn't working for me.
(Offline)   Reply With Quote
Old 05-05-2009, 07:19 PM   #237 (permalink)
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
Quote:
Originally Posted by The Gunner View Post
Any word on when version 1 will hit iTunes? The adhoc isn't working for me.
No, Apple tells you nothing but shut up and wait. It's really annoying.
(Offline)   Reply With Quote
Old 05-05-2009, 08:10 PM   #238 (permalink)
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
Ok need somebody who's better at php than me.

This accepts an url with a variable like ?dev=<11111 11111 1111 11111>

and writes it to a log file with <deviceToken></deviceToken> wrapped around it. Whats the best way to check for and remove duplicate entries.

Code:
<?php
	$deviceToken=$_GET['dev'];
	
	$filename = 'tokenLog';
	$front = '<deviceToken>';
	$back = '</deviceToken>';
	// Let's make sure the file exists and is writable first.
	if (is_writable($filename)) {
	    // In our example we're opening $filename in append mode.
	    // The file pointer is at the bottom of the file hence
	    // that's where $clientMessage will go when we fwrite() it.
	    if (!$handle = fopen($filename, 'a')) {
	         echo "Cannot open file ($filename)";
	         exit;
	    }
	    // Write $clientMessage to our opened file.
	    if (fwrite($handle, $front.$deviceToken.$back) === FALSE) {
	        echo "Cannot write to file ($filename)";
	        exit;
	    }
	    echo "Success, wrote ($clientMessage) to file ($filename)";
	    fclose($handle);
	} else {
	    echo "The file $filename is not writable";
	}
?>
and

Code:
<deviceToken><c32f8b7c e8d02a51 ce296c62 d3da4cb3 84fed78d b24545db fd949a73 132f2b50></deviceToken>
(Offline)   Reply With Quote
Old 05-05-2009, 08:19 PM   #239 (permalink)
Senior Member
 
dzagama's Avatar
 
Join Date: May 2007
Location: pacinian corpuscle.
Posts: 1,868
Can you keep the entries in a hash table in memory and dump to file periodically?

Checking for dupes each time you write to a file is gonna be a bottleneck.

But I haven't hit this thread up in a while. Lemme reed thru the archives.
(Offline)   Reply With Quote
Old 05-05-2009, 08:24 PM   #240 (permalink)
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
Quote:
Originally Posted by dzagama View Post
Can you keep the entries in a hash table in memory and dump to file periodically?

Checking for dupes each time you write to a file is gonna be a bottleneck.

But I haven't hit this thread up in a while. Lemme reed thru the archives.
I might write a python script and set it up as a cron job. Might just do it in the push notification app. If there's an effective way to do it using something like pythons sets I would be into that.
(Offline)   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT -5. The time now is 08:51 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Keith and The Girl