<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Computer Electric Bacon</title>
	<atom:link href="http://electricbacon.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://electricbacon.wordpress.com</link>
	<description>It&#039;s Sizzling &#38; Delicious</description>
	<lastBuildDate>Wed, 27 Oct 2010 23:10:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='electricbacon.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Computer Electric Bacon</title>
		<link>http://electricbacon.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://electricbacon.wordpress.com/osd.xml" title="Computer Electric Bacon" />
	<atom:link rel='hub' href='http://electricbacon.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Setting a %PATH% variable</title>
		<link>http://electricbacon.wordpress.com/2010/10/27/setting-a-path-variable/</link>
		<comments>http://electricbacon.wordpress.com/2010/10/27/setting-a-path-variable/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 23:01:39 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[%PATH%]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=237</guid>
		<description><![CDATA[This is important to remember because sometimes we need to run something from the command line, and then we get a &#8220;is not recognized as an internal or external command, operable program or batch file.&#8221; error message. First echo the variable into the command line, like this C:\echo %PATH% Then we want to append a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=237&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is important to remember because sometimes we need to run something from the command line, and then we get a &#8220;is not recognized as an internal or external command, operable program or batch file.&#8221; error message.</p>
<p>First echo the variable into the command line, like this</p>
<pre><code><strong><strong>C:\echo %PATH%</strong></strong></code></pre>
<p>Then we want to append a new path into this %PATH% variable, like this</p>
<pre><code><strong>C:\set PATH=%PATH%;C:\j2sdk1.4.2_01\bin</strong>
</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=237&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/10/27/setting-a-path-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Calc Example using SWI-Prolog and C++</title>
		<link>http://electricbacon.wordpress.com/2010/09/08/calc-example-using-swi-prolog-and-c/</link>
		<comments>http://electricbacon.wordpress.com/2010/09/08/calc-example-using-swi-prolog-and-c/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 06:41:07 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=233</guid>
		<description><![CDATA[I wrote the calc example and confirm that it works. It can be found here. I performed some changes to it since I am not running from the command line. First I&#8217;ll show you the main.cpp #include &#60;iostream&#62; #include &#60;SWI-Prolog.h&#62; using namespace std; int main(void){ static char * av[] = {"calc.pl", NULL}; if( ! PL_initialise(1,av)){ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=233&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wrote the calc example and confirm that it works. It can be found <a href="http://www.swi-prolog.org/pldoc/doc_for?object=section%283%2c%279.5.1%27%2cswi%28%27%2fdoc%2fManual%2fplld.html%27%29%29">here</a>. I performed some changes to it since I am not running from the command line.</p>
<p>First I&#8217;ll show you the main.cpp</p>
<pre>#include &lt;iostream&gt;
#include &lt;SWI-Prolog.h&gt;

using namespace std;

int main(void){

 static char * av[] = {"calc.pl", NULL};
 if( ! PL_initialise(1,av)){
 cout&lt;&lt;"error initializing"&lt;&lt;endl;
 PL_halt(1);
 }else {
 cout&lt;&lt;"success initializing!"&lt;&lt;endl;
 }

 predicate_t pred = PL_predicate("calc",1,"user");
 term_t h0 = PL_new_term_refs(1);

 int rval;
 char * expression = "pi/2";
 PL_put_atom_chars(h0,expression);
 rval = PL_call_predicate(NULL, PL_Q_NORMAL, pred, h0);
 PL_halt( rval ? 0 : 1 );

 return 0;
}</pre>
<p>Secondly I&#8217;ll show you calc.pl. It is a prolog file.</p>
<pre>calc(Atom) :-
 term_to_atom(Expr, Atom),
 A is Expr,
 write(A),
 nl.
</pre>
<p>I&#8217;ll admit that&#8217;s pretty straight forward! <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=233&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/09/08/calc-example-using-swi-prolog-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up SWI-Prolog with C++</title>
		<link>http://electricbacon.wordpress.com/2010/09/08/setting-up-swi-prolog-with-c/</link>
		<comments>http://electricbacon.wordpress.com/2010/09/08/setting-up-swi-prolog-with-c/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 06:12:42 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=225</guid>
		<description><![CDATA[Here&#8217;s a quick walk-through on how to set up SWI-Prolog with C++. Download SWI-Prolog from here. I downloaded version 5.4.7 because in version 5.10.1 I could not find the necessary libpl.dll file that is mentioned in the documentation. In Control Panel -&#62; System -&#62;Advanced-&#62; Environment Variables. Set the %PATH% variable to point to the bin [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=225&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick walk-through on how to set up SWI-Prolog with C++.</p>
<ol>
<li>Download SWI-Prolog from <a href="http://www.swi-prolog.org/download/stable" target="_blank">here</a>. I downloaded version 5.4.7 because in version 5.10.1 I could not find the necessary libpl.dll file that is mentioned in the documentation.</li>
<li>In Control Panel -&gt; System -&gt;Advanced-&gt; Environment Variables.<br />
Set the %PATH% variable to point to the bin SWI-Prolog folder by clicking edit and then pasting the path.<br />
On a default install path should be &#8220;C:\Program Files\pl\bin&#8221;.<br />
<a href="http://electricbacon.files.wordpress.com/2010/09/envariables.png"><img class="alignnone size-medium wp-image-226" title="envariables" src="http://electricbacon.files.wordpress.com/2010/09/envariables.png?w=270&#038;h=300" alt="" width="270" height="300" /></a><br />
<a href="http://electricbacon.files.wordpress.com/2010/09/envariables2.png"><img class="alignnone size-medium wp-image-227" title="envariables2" src="http://electricbacon.files.wordpress.com/2010/09/envariables2.png?w=300&#038;h=128" alt="" width="300" height="128" /></a></li>
<li>Create an empty visual studio project with an empty main.cpp file.</li>
<li>Configure the visual studio include directory .<br />
<a href="http://electricbacon.files.wordpress.com/2010/09/vsinclude1.png"><img class="alignnone size-medium wp-image-228" title="vsinclude1" src="http://electricbacon.files.wordpress.com/2010/09/vsinclude1.png?w=300&#038;h=208" alt="" width="300" height="208" /></a></li>
<li>Configure the visual studio  linker input.<br />
<a href="http://electricbacon.files.wordpress.com/2010/09/vsinclude2.png"><img class="alignnone size-medium wp-image-229" title="vsinclude2" src="http://electricbacon.files.wordpress.com/2010/09/vsinclude2.png?w=300&#038;h=208" alt="" width="300" height="208" /></a></li>
<li>Paste the following code in the main.cpp</li>
<pre>#include &lt;iostream&gt;
#include &lt;SWI-Prolog.h&gt;

using namespace std;

int main(void){

 static char * av[] = {"libpl.dll", NULL};
 if( ! PL_initialise(1,av)){
 cout&lt;&lt;"error initializing"&lt;&lt;endl;
 }else {
 cout&lt;&lt;"success initializing!"&lt;&lt;endl;
 }
 return 0;
}</pre>
<li>Buidl It! Start without Debug! It works!<br />
<a href="http://electricbacon.files.wordpress.com/2010/09/swiprologcpp.png"><img class="alignnone size-medium wp-image-230" title="swiprolog&amp;cpp" src="http://electricbacon.files.wordpress.com/2010/09/swiprologcpp.png?w=300&#038;h=135" alt="" width="300" height="135" /></a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=225&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/09/08/setting-up-swi-prolog-with-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>

		<media:content url="http://electricbacon.files.wordpress.com/2010/09/envariables.png?w=270" medium="image">
			<media:title type="html">envariables</media:title>
		</media:content>

		<media:content url="http://electricbacon.files.wordpress.com/2010/09/envariables2.png?w=300" medium="image">
			<media:title type="html">envariables2</media:title>
		</media:content>

		<media:content url="http://electricbacon.files.wordpress.com/2010/09/vsinclude1.png?w=300" medium="image">
			<media:title type="html">vsinclude1</media:title>
		</media:content>

		<media:content url="http://electricbacon.files.wordpress.com/2010/09/vsinclude2.png?w=300" medium="image">
			<media:title type="html">vsinclude2</media:title>
		</media:content>

		<media:content url="http://electricbacon.files.wordpress.com/2010/09/swiprologcpp.png?w=300" medium="image">
			<media:title type="html">swiprolog&#38;cpp</media:title>
		</media:content>
	</item>
		<item>
		<title>C++ Converting from String to Int using atoi()</title>
		<link>http://electricbacon.wordpress.com/2010/08/24/c-converting-from-string-to-int-using-atoi/</link>
		<comments>http://electricbacon.wordpress.com/2010/08/24/c-converting-from-string-to-int-using-atoi/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 02:28:40 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[atoi]]></category>
		<category><![CDATA[convert]]></category>

		<guid isPermaLink="false">http://mxxxhxxx.net/portfolio/?p=169</guid>
		<description><![CDATA[Perhaps the least fun thing about C++ is type conversion. It is my mission to post simple examples on the web so that you may search, find and say &#8220;AHA!&#8221;. I will reveal two ways of converting String to Int. Old fashioned! Iterate through a string using an integer index &#8220;i&#8221; String s = "12343456" for( [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=169&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Perhaps the least fun thing about C++ is type conversion. It is my mission to post simple examples on the web so that you may search, find and say &#8220;AHA!&#8221;.<br />
I will reveal two ways of converting String to Int.</p>
<p>Old fashioned! Iterate through a string using an integer index &#8220;i&#8221;</p>
<pre>
String s = "12343456"
for( int i = 0; i != s.size(); i++)
{
	int number = atoi(&amp;s[i]);
	cout&lt;&lt; &quot;number : &quot; &lt;&lt; number &lt;&lt; endl;
}
</pre>
<p>Correct way! Iterate through the string using a string::iterator &#8220;i&#8221;</p>
<pre>
String s = "12345678"
for( string::iterator i = s.begin() ; i != s.end(); i++)
{
	int number = atoi(&amp;*i);
	cout&lt;&lt; &quot;number : &quot; &lt;&lt; number &lt;&lt; endl;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=169&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/08/24/c-converting-from-string-to-int-using-atoi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Winsock Programming</title>
		<link>http://electricbacon.wordpress.com/2010/07/15/winsock-programming/</link>
		<comments>http://electricbacon.wordpress.com/2010/07/15/winsock-programming/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 08:28:05 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Miguel A Herrera G]]></category>

		<guid isPermaLink="false">http://mxxxhxxx.net/portfolio/?p=164</guid>
		<description><![CDATA[This is just the basic example of winsock programming. In this sample I set up a server in the following order. Initialize Winsock Create Socket Bind Socket Listen for a Client Accept Connection Receive and Send Disconnect. Basically I see bee &#38; Lard.  I also create a client that will talk to the server on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=164&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just the basic example of winsock programming. In this sample I set up a server in the following order.</p>
<p>Initialize Winsock</p>
<p>Create Socket</p>
<p>Bind Socket</p>
<p>Listen for a Client</p>
<p>Accept Connection</p>
<p>Receive and Send</p>
<p>Disconnect.</p>
<p>Basically I see bee &amp; Lard.  <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I also create a client that will talk to the server on a specific port. I do this in the following order.</p>
<p>Initialize Winsock</p>
<p>Create Socket</p>
<p>Connect to server</p>
<p>Send and Recieve</p>
<p>Disconnect</p>
<p>First I will show you the client code</p>
<pre>#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#pragma comment(lib, "ws2_32.lib")

#pragma comment(lib, "wsock32.lib")

#include
#include
#include
#include
#include
#define DEFAULT_PORT "27016"
#define DEFAULT_BUFLEN 512

void main(int argc, char *argv[] )  {

	WSADATA wsaData;
	int iResult;
	//
	// Initialize Winsock
	//
	iResult = WSAStartup(MAKEWORD(2,2), &amp;wsaData);
	if (iResult != 0) {
		printf("WSAStartup failed: %d\n", iResult);
	}

	struct addrinfo *result = NULL;
	struct addrinfo  *ptr = NULL;
	struct addrinfo hints;

	ZeroMemory( &amp;hints, sizeof(hints) );
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;

	// Resolve the server address and port
	iResult = getaddrinfo(argv[1], DEFAULT_PORT, &amp;hints, &amp;result);
	if (iResult != 0) {
		printf("getaddrinfo failed: %d\n", iResult);
		WSACleanup();

	}
	//
	// This is the Socket
	//
	SOCKET ConnectSocket = INVALID_SOCKET;
	// Attempt to connect to the first address returned by
	// the call to getaddrinfo
	ptr=result;

	// Create a SOCKET for connecting to server
	ConnectSocket = socket(ptr-&gt;ai_family, ptr-&gt;ai_socktype,
		ptr-&gt;ai_protocol);

	if (ConnectSocket == INVALID_SOCKET) {
		printf("Error at socket(): %ld\n", WSAGetLastError());
		freeaddrinfo(result);
		WSACleanup();
	}
	// Connect to server.
	iResult = connect( ConnectSocket, ptr-&gt;ai_addr, (int)ptr-&gt;ai_addrlen);
	if (iResult == SOCKET_ERROR) {
		closesocket(ConnectSocket);
		ConnectSocket = INVALID_SOCKET;
	}
	// Should really try the next address returned by getaddrinfo
	// if the connect call failed
	// But for this simple example we just free the resources
	// returned by getaddrinfo and print an error message

	freeaddrinfo(result);

	if (ConnectSocket == INVALID_SOCKET) {
		printf("Unable to connect to server!\n");
		WSACleanup();

	}

	int recvbuflen = DEFAULT_BUFLEN;

	char *sendbuf = "this is a test";
	char recvbuf[DEFAULT_BUFLEN];

	// Send an initial buffer
	iResult = send(ConnectSocket, sendbuf, (int) strlen(sendbuf), 0);
	if (iResult == SOCKET_ERROR) {
		printf("send failed: %d\n", WSAGetLastError());
		closesocket(ConnectSocket);
		WSACleanup();

	}

	printf("Bytes Sent: %ld\n", iResult);

	// shutdown the connection for sending since no more data will be sent
	// the client can still use the ConnectSocket for receiving data
	iResult = shutdown(ConnectSocket, SD_SEND);
	if (iResult == SOCKET_ERROR) {
		printf("shutdown failed: %d\n", WSAGetLastError());
		closesocket(ConnectSocket);
		WSACleanup();

	}

	// Receive data until the server closes the connection
	do {
		iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
		if (iResult &gt; 0)
			printf("Bytes received: %d\n", iResult);
		else if (iResult == 0)
			printf("Connection closed\n");
		else
			printf("recv failed: %d\n", WSAGetLastError());
	} while (iResult &gt; 0);

	// shutdown the send half of the connection since no more data will be sent
	iResult = shutdown(ConnectSocket, SD_SEND);
	if (iResult == SOCKET_ERROR) {
		printf("shutdown failed: %d\n", WSAGetLastError());
		closesocket(ConnectSocket);
		WSACleanup();

	}

	// cleanup
	closesocket(ConnectSocket);
	WSACleanup();
}
</pre>
<p>Now I will throw the server code at you.</p>
<pre>#define WIN32_LEAN_AND_MEAN

#include
#include
#include
#include
#include

// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")

#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "27016"

int __cdecl main(void)
{
    WSADATA wsaData;
    SOCKET ListenSocket = INVALID_SOCKET,
           ClientSocket = INVALID_SOCKET;
    struct addrinfo *result = NULL,
                    hints;
    char recvbuf[DEFAULT_BUFLEN];
    int iResult, iSendResult;
    int recvbuflen = DEFAULT_BUFLEN;

    // Initialize Winsock
    iResult = WSAStartup(MAKEWORD(2,2), &amp;wsaData);
    if (iResult != 0) {
        printf("WSAStartup failed: %d\n", iResult);
        return 1;
    }

    ZeroMemory(&amp;hints, sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;
    hints.ai_flags = AI_PASSIVE;

    // Resolve the server address and port
    iResult = getaddrinfo(NULL, DEFAULT_PORT, &amp;hints, &amp;result);
    if ( iResult != 0 ) {
        printf("getaddrinfo failed: %d\n", iResult);
        WSACleanup();
        return 1;
    }

    // Create a SOCKET for connecting to server
    ListenSocket = socket(result-&gt;ai_family, result-&gt;ai_socktype, result-&gt;ai_protocol);
    if (ListenSocket == INVALID_SOCKET) {
        printf("socket failed: %ld\n", WSAGetLastError());
        freeaddrinfo(result);
        WSACleanup();
        return 1;
    }

    // Setup the TCP listening socket
    iResult = bind( ListenSocket, result-&gt;ai_addr, (int)result-&gt;ai_addrlen);
    if (iResult == SOCKET_ERROR) {
        printf("bind failed: %d\n", WSAGetLastError());
        freeaddrinfo(result);
        closesocket(ListenSocket);
        WSACleanup();
        return 1;
    }

    freeaddrinfo(result);

    iResult = listen(ListenSocket, SOMAXCONN);
    if (iResult == SOCKET_ERROR) {
        printf("listen failed: %d\n", WSAGetLastError());
        closesocket(ListenSocket);
        WSACleanup();
        return 1;
    }

    // Accept a client socket
    ClientSocket = accept(ListenSocket, NULL, NULL);
    if (ClientSocket == INVALID_SOCKET) {
        printf("accept failed: %d\n", WSAGetLastError());
        closesocket(ListenSocket);
        WSACleanup();
        return 1;
    }

    // No longer need server socket
    closesocket(ListenSocket);

    // Receive until the peer shuts down the connection
    do {

        iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
        if (iResult &gt; 0) {
            printf("Bytes received: %d\n", iResult);

        // Echo the buffer back to the sender
            iSendResult = send( ClientSocket, recvbuf, iResult, 0 );
            if (iSendResult == SOCKET_ERROR) {
                printf("send failed: %d\n", WSAGetLastError());
                closesocket(ClientSocket);
                WSACleanup();
                return 1;
            }
            printf("Bytes sent: %d\n", iSendResult);
        }
        else if (iResult == 0)
            printf("Connection closing...\n");
        else  {
            printf("recv failed: %d\n", WSAGetLastError());
            closesocket(ClientSocket);
            WSACleanup();
            return 1;
        }

    } while (iResult &gt; 0);

    // shutdown the connection since we're done
    iResult = shutdown(ClientSocket, SD_SEND);
    if (iResult == SOCKET_ERROR) {
        printf("shutdown failed: %d\n", WSAGetLastError());
        closesocket(ClientSocket);
        WSACleanup();
        return 1;
    }

    // cleanup
    closesocket(ClientSocket);
    WSACleanup();

    return 0;
}
</pre>
<p>Things to watch out for</p>
<p>bind failed 10048: This basically means that the port you are requesting is already in use. No problem</p>
<p>getaddrinfo failed: 11001:  This one means that there is not server listening on the port you are requesting.</p>
<p>This sample code is not even close to a real world server.  This code only receives a message and then dies.</p>
<p>Next sample will be of a server that is continuously listening to requests.</p>
<p>Good Luck!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=164&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/07/15/winsock-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert Multiple Videos using mEncoder</title>
		<link>http://electricbacon.wordpress.com/2010/04/25/convert-multiple-videos-using-mencoder/</link>
		<comments>http://electricbacon.wordpress.com/2010/04/25/convert-multiple-videos-using-mencoder/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 02:07:23 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Video Topics]]></category>
		<category><![CDATA[bat file]]></category>
		<category><![CDATA[mkv]]></category>
		<category><![CDATA[omg]]></category>
		<category><![CDATA[ps3]]></category>
		<category><![CDATA[video encoding]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=57</guid>
		<description><![CDATA[If you have a ps3, then I am sure you are trying to convert .mkv or .omg files so that you may view them on the console. Problem is that most articles on the web talk about converting only one file. Once again I bring an article that is bullshit free. In this post I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=57&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have a ps3, then I am sure you are trying to convert .mkv or .omg files so that you may view them on the console.<br />
Problem is that most articles on the web talk about converting only one file. Once again I bring an article that is bullshit free.<br />
In this post I talk about how to write a .bat file that will read all .mkv or .omg files in a source folder of your choice, and will encode them to .avi in the destination folder of your choice. Lets go!</p>
<p>0. Download mEncoder. (Look that shit up!)</p>
<p>1. Create a new text file.</p>
<pre>

@echo off
SET count=0
SET source=%1
SET dest=%2

mkdir %dest%

FOR /f "tokens=*" %%G IN ('dir %source% /b') DO (call :s_do_sums "%%G")
GOTO :eof

:s_do_sums
echo %count%:%1
mencoder.exe %source%/"%1" -oac mp3lame -ovc copy -o %dest%\Robotech.Remastered.%count%.avi
set /a count+=1
GOTO :eof
</pre>
<p>2 Save it as &#8220;batchconvert.bat&#8221; in &#8220;../Program Files/menconder&#8221;.</p>
<p>3. Run cmd</p>
<p>Example:</p>
<p>C:\Program Files\mencoder\batchconvert.bat C:\vuze\robotech F:\videos\robotech</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=57&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/04/25/convert-multiple-videos-using-mencoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>AppleScript Move a File to Trash</title>
		<link>http://electricbacon.wordpress.com/2010/03/22/applescript-move-a-file-to-trash/</link>
		<comments>http://electricbacon.wordpress.com/2010/03/22/applescript-move-a-file-to-trash/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 19:30:31 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=54</guid>
		<description><![CDATA[Without the all the unnecessary bullshit! Here&#8217;s how to trash a file using applescript. tell application "Finder" move POSIX file "/Users/Me/test.txt" to trash end tell<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=54&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Without the all the unnecessary bullshit!<br />
Here&#8217;s how to trash a file using applescript.</p>
<pre>
tell application "Finder"
move POSIX file "/Users/Me/test.txt" to trash
end tell
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=54&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/03/22/applescript-move-a-file-to-trash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting a const char * into a wchar_t</title>
		<link>http://electricbacon.wordpress.com/2010/03/15/converting-a-const-char-into-a-wchar_t/</link>
		<comments>http://electricbacon.wordpress.com/2010/03/15/converting-a-const-char-into-a-wchar_t/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 22:44:28 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[char*]]></category>
		<category><![CDATA[CString]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Wchar_t]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=49</guid>
		<description><![CDATA[This is for converting a multibyte string back into a wide c-style string. Useful for sending strings from a Java program that uses JNA into a windows MFC Dll. void returnWChar_T(const char * someConstCharStar) { wchar_t buffer[10000]; mbstowcs(buffer, someConstCharStar, sizeof(buffer); return buffer; }<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=49&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is for converting a multibyte string back into a wide c-style string. Useful for sending strings from a Java program that uses JNA into a windows MFC Dll.</p>
<pre>

void returnWChar_T(const char * someConstCharStar)
{
wchar_t buffer[10000];
mbstowcs(buffer, someConstCharStar, sizeof(buffer);
return buffer;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=49&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/03/15/converting-a-const-char-into-a-wchar_t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting a CString to a Char*</title>
		<link>http://electricbacon.wordpress.com/2010/03/15/converting-a-cstring-to-a-char/</link>
		<comments>http://electricbacon.wordpress.com/2010/03/15/converting-a-cstring-to-a-char/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 22:04:06 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[char*]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=45</guid>
		<description><![CDATA[Wow! This is for converting a CString into a multibyte string. Useful for sending mfc CStrings to a Java program that uses JNA. char* returnCharStar(void) { Cstring szMsg = "Hello, World!"; char buffer[1000]; wcstombs(buffer, szMsg, sizeof(buffer)); szMsg.ReleaseBuffer(); return buffer; }<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=45&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow! This is for converting a CString into a multibyte string.<br />
Useful for sending mfc CStrings to a Java program that uses JNA.</p>
<pre>

char* returnCharStar(void)
{
Cstring szMsg = "Hello, World!";

char buffer[1000];
wcstombs(buffer, szMsg, sizeof(buffer));
szMsg.ReleaseBuffer();

return buffer;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=45&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/03/15/converting-a-cstring-to-a-char/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
		<item>
		<title>On Writing a DLL and Using it with JNA</title>
		<link>http://electricbacon.wordpress.com/2010/03/12/on-writing-a-dll-and-using-it-with-jna/</link>
		<comments>http://electricbacon.wordpress.com/2010/03/12/on-writing-a-dll-and-using-it-with-jna/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 20:03:01 +0000</pubDate>
		<dc:creator>darkironcross</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DLL Tutorial]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JNA]]></category>

		<guid isPermaLink="false">http://electricbacon.wordpress.com/?p=37</guid>
		<description><![CDATA[Writing DLL&#8217;s can be kind of a pain in the ass, especially if you are following tutorial articles that needlessly over-complicate shit. In this article you will learn how to write a DLL, and then have Java code load it using JNA without the extra bullshit. Let&#8217;s get er done. Here&#8217;s the source cpp file. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=37&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Writing DLL&#8217;s can be kind of a pain in the ass, especially if you are following tutorial articles that needlessly over-complicate shit. In this article you will learn how to write a DLL, and then have Java code load it using JNA without the extra bullshit.<br />
Let&#8217;s get er done.</p>
<p>Here&#8217;s the source cpp file.</p>
<pre>// dlltest.cpp 

#include "stdafx.h"
#include "dlltest.h"

extern "C" __declspec(dllexport)

void HelloWorld(void)
{
   MessageBox( NULL, TEXT("Hello World"), TEXT("In a DLL"), MB_OK);
}</pre>
<p>Note: Dll&#8217;s don&#8217;t need to have an entry point if you are not going to register them.<br />
Btw I&#8217;m not including code for stdafx.h, that shit is generated for you by visual studio and is very common.<br />
Ok, now the header file</p>
<pre>// dlltest.h

#ifdef DLLTEST_EXPORTS
#define DLLTEST_API __declspec(dllexport)
#else
#define DLLTEST_API __declspec(dllimport)
#endif

extern "C" __declspec(dllexport) void HelloWorld(void);</pre>
<p>Now for the Java Code that will use this DLL.</p>
<pre>
import com.sun.jna.Library;
import com.sun.jna.Native;

public class DllLoad {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		DllTest.INSTANCE.HelloWorld();

	}

	public interface DllTest extends Library {

		DllTest INSTANCE = (DllTest) Native
				.loadLibrary(
						"C:/blabla/dlltest.dll",
						DllTest.class);

		void HelloWorld();
	}

}
</pre>
<p>Done!</p>
<p>Note: extern &#8220;C&#8221; is super important. If you don&#8217;t put that shit in there Java will give you endless headaches of errors saying &#8220;java.lang.UnsatisfiedLinkError: &#8211; (bla bla bla) -The specified procedure could not be found.&#8221;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/electricbacon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/electricbacon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/electricbacon.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=electricbacon.wordpress.com&amp;blog=10266823&amp;post=37&amp;subd=electricbacon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://electricbacon.wordpress.com/2010/03/12/on-writing-a-dll-and-using-it-with-jna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e4f47be4100793b7a7f3c812860779?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">darkironcross</media:title>
		</media:content>
	</item>
	</channel>
</rss>
