我目前正在开发一个可以接受来自多个客户端计算机的多个连接的C#Socket服务器.服务器的目标是允许客户端从服务器事件"订阅"和"取消订阅".
到目前为止,我已经在这里采取了一个快乐的好看:http://msdn.microsoft.com/en-us/library/5w7b7x5f( v = VS.100).aspx和http://msdn.microsoft.com/ en-us/library/fx6588te.aspx的想法.
我发送的所有消息都是加密的,所以我接收了我希望发送的字符串消息,将其转换为byte []数组,然后在将消息长度预先挂起到数据之前加密数据并通过连接发送出去.
令我印象深刻的一件事是:在接收端,当收到消息的一半时,Socket.EndReceive()(或相关的回调)似乎可能会返回.是否有一种简单的方法可以确保每封邮件都"完整"并且一次只收到一封邮件?
编辑:例如,我认为.NET/Windows套接字没有"包装"消息,以确保在一个Socket.Receive()调用中收到与Socket.Send()一起发送的单个消息?或者是吗?
到目前为止我的实施:
private void StartListening()
{
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint localEP = new IPEndPoint(ipHostInfo.AddressList[0], Constants.PortNumber);
Socket listener = new Socket(localEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEP);
listener.Listen(10);
while (true)
{
// Reset the event.
this.listenAllDone.Reset();
// Begin waiting for a connection
listener.BeginAccept(new AsyncCallback(this.AcceptCallback), listener);
// Wait for the event.
this.listenAllDone.WaitOne();
}
}
private void AcceptCallback(IAsyncResult ar)
{
// Get the socket that handles the client …Run Code Online (Sandbox Code Playgroud) 我目前的设计是这样的:我有一个显示主应用程序的外框.当用户单击主应用程序上的按钮时,应启动弹出窗口.我正在使用JOptionPane.showInternalOptionDialog并将按钮对象作为选项传递.当用户单击其中一个按钮时,它应该运行某些命令然后关闭窗口.我无法关闭显示弹出窗口的Frame.
我在这个论坛中发现了类似的问题,建议采用以下解决方法. 关闭JOptionPane.showOptionDialog()创建的对话框
但上面的解决方法关闭了我的完整gui.我只想关闭JOptionPane弹出窗口.
提前致谢.
下面的函数接受一个数组并检查其键和值是否与指定的数据类型匹配.
我似乎遇到了以前工作的内部lambda函数的一些问题.我正在运行PHP v5.3.6.他们最后在v5.3.4下工作.他们抱怨未通过的变量不在范围内.如果我重新声明该变量,global则错误消失,但变量为空.
/**
* @param array $arr, array to be tested
* @param mixed $keytype
* @param mixed $valuetype
* @example acceptable_arr( array(1,2,3,4,'string'), NULL, 'integer') returns false
* @example acceptable_arr( array('thing'=>1,'other'=>2), 'string', 'integer') returns true
* @example acceptable_arr( array('thing'=>1,'other'=>2), 'string', 'array') returns false
*/
function acceptable_arr(array $arr,$keytype=NULL,$valuetype=NULL){
print_r(func_get_args()); //debugging
$valfail=true; $keyfail=true;
if($keytype==NULL && $valuetype==NULL) return true;
if(!is_null($keytype)) {
$keytest='is_'.$keytype;
if(function_exists($keytest)){
$fn_kfail=function($v){return call_user_func($keytest,$v);}; //PROBLEM LINE 218
$keyfail=(!is_null($keytype)) ? array_sum(array_map($fn_kfail,array_keys($arr))) : false;
}
}
if(!is_null($valuetype)) {
$valtest='is_'.$valuetype;
if(function_exists($valtest)){
$fn_vfail=function($v){return …Run Code Online (Sandbox Code Playgroud) 在拥有类:
...
@Embedded
private LatLon location;
...
Run Code Online (Sandbox Code Playgroud)
在引用的类中:
@Embeddable
public class LatLon implements Serializable {
private double lat;
private double lon;
...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用null值保存拥有类的实例时LatLon:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.*.location.
如何在拥有类中允许此值为null?我试过制作它Nullable并没有效果.
我只是有一个简短的问题.我注意到我的编译器中没有stdafx.h(windows上的mingw32)
我应该拥有它吗?或者也许有办法解决它?
谢谢阅读
编辑:好的,这是我当前的构建日志,一旦我拿出了stdafx.h的所有包含
我有:
问题:它执行两次整个清单.
尝试:我已经修改了waitInterval和waitAttempts认为它已经超时并重新开始,但是没有帮助.
问题:可能使它执行两次?
清单:
<sitemanifest>
<runCommand path="net stop TestSvc"
waitInterval="240000"
waitAttempts="1"/>
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<dirPath path="C:\msdeploy\TestSvc\TestSvc\bin\Debug" />
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<runCommand path="net start TestSvc"
waitInterval="240000"
waitAttempts="1"/>
</sitemanifest>
Run Code Online (Sandbox Code Playgroud)
发出包装命令:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:manifest=c:\msdeploy\custom.xml
-dest:package=c:\msdeploy\package.zip
Run Code Online (Sandbox Code Playgroud)
发出执行它的命令:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:package=c:\msdeploy\package.zip
-dest:auto,computername=<computerNameHere>
Run Code Online (Sandbox Code Playgroud)
我作为具有管理访问权限的域用户运行.我也尝试过传递凭据 - 这不是权限问题,命令是成功的,只执行两次.
编辑:
我启用-verbose并在日志中找到了一些有趣的行:
详细:执行同步传递#1.
...
详细:源文件路径(C:\ msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe)与属性不同的目标(C:\ msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe)不匹配(lastWriteTime [ '11/08/2011 23:40:30','11/08/2011 23:39:52']).更新待定.
详细:源文件路径(C:\ msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb)与属性不同的目标(C:\ msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb)不匹配(lastWriteTime [ '11/08/2011 23:40:30','11/08/2011 23:39:52']).更新待定.
在这些行之后,第一次不复制文件,而是第二次复制文件 …
我想在 observablecollection 中复制一个列表项。当我做:
TreasureCards[TreasureCards.Count - 1] = TreasureCards[CardPosition];
Run Code Online (Sandbox Code Playgroud)
它创建了特定列表项的副本,但随后它们在我的 UI 中链接。因此,如果我更改新重复项的名称,它会更改原始名称。我知道我可以一个一个地完成每个属性(见下文),但有没有办法只复制整个项目?
TreasureCards[TreasureCards.Count - 1].Name = TreasurecCards[CardPosition].Name;
TreasureCards[TreasureCards.Count - 1].Type= TreasurecCards[CardPosition].Type;
// etc
Run Code Online (Sandbox Code Playgroud) 我通过Django访问的遗留数据库有一个表列,它以下列字符串格式存储序列化数据:
a:5:{i:1;s:4:"1869";i:2;s:4:"1859";i:3;s:4:"1715";i:4;s:1:"0";i:5;s:1:"0";}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以使用python/python-library将其更改为列表或任何其他友好的python数据类型,以进一步处理单个值?
注意:这些值是通过PHP写入数据库的.
我通过执行以下操作,在 C# 中以编程方式对元素的两个 RenderTransform 进行动画处理:
Storyboard.SetTargetProperty(shiftAnimation, new PropertyPath("RenderTransform.X"));
Run Code Online (Sandbox Code Playgroud)
问题是,现在我使用两个变换,我需要添加一个 TransformGroup。但我无法弄清楚如何使用它访问路径。
TransformGroup.RenderTransform.X或任何类似的东西都不起作用。
我有一个大型Java库,但只需要一小部分.我如何提取主类及其所有依赖项?自动化解决方案将是首选,但我也可以使用生成我需要提取的文件列表的东西(我不想自己编写这些东西 ;-)).
这类似于工具或插件来从VS项目中提取类及其所有依赖项 - 我只需要它用于Java(使用的IDE是Eclipse).
c# ×3
java ×2
wpf ×2
.net ×1
asynchronous ×1
c++ ×1
codeblocks ×1
deployment ×1
django ×1
embeddable ×1
embedded ×1
hibernate ×1
iis ×1
joptionpane ×1
lambda ×1
mingw32 ×1
msdeploy ×1
php ×1
php-5.3 ×1
python ×1
sockets ×1
stdafx.h ×1
swing ×1
tcp ×1